[FFmpeg-devel] [PATCH 1/2] libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct

Michael Niedermayer michael at niedermayer.cc
Thu Mar 17 19:33:28 CET 2016


On Thu, Mar 17, 2016 at 01:15:23PM -0300, James Almer wrote:
> On 3/17/2016 1:02 PM, Michael Niedermayer wrote:
> > On Thu, Mar 17, 2016 at 11:06:29AM -0300, James Almer wrote:
> >> On 3/17/2016 4:32 AM, wm4 wrote:
> >>> On Thu, 17 Mar 2016 01:03:49 -0300
> >>> James Almer <jamrial at gmail.com> wrote:
> >>>
> >>>> This zeroes the WebPAnimEncoderOptions.verbose field, silencing library info messages
> >>>> printed to stderr.
> >>>>
> >>>> Signed-off-by: James Almer <jamrial at gmail.com>
> >>>> ---
> >>>>  libavcodec/libwebpenc_animencoder.c | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c
> >>>> index d7437a9..35c456a 100644
> >>>> --- a/libavcodec/libwebpenc_animencoder.c
> >>>> +++ b/libavcodec/libwebpenc_animencoder.c
> >>>> @@ -41,7 +41,7 @@ static av_cold int libwebp_anim_encode_init(AVCodecContext *avctx)
> >>>>      int ret = ff_libwebp_encode_init_common(avctx);
> >>>>      if (!ret) {
> >>>>          LibWebPAnimContext *s = avctx->priv_data;
> >>>> -        WebPAnimEncoderOptions enc_options;
> >>>> +        WebPAnimEncoderOptions enc_options = { 0 };
> >>>>          WebPAnimEncoderOptionsInit(&enc_options);
> >>>>          // TODO(urvang): Expose some options on command-line perhaps.
> >>>>          s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options);
> >>>
> >>> Does this mean it was reading uninitialized values from the stack?
> >>
> >> Apparently. Should i backport this?
> > 
> > please backport if older releases are affected
> 
> 2.7 and newer, yes.
> 
> > 
> > also my gcc is not fully happy about this:
> > libavcodec/libwebpenc_animencoder.c: In function ‘libwebp_anim_encode_init’:
> > libavcodec/libwebpenc_animencoder.c:44:9: warning: missing braces around initializer [-Wmissing-braces]
> > libavcodec/libwebpenc_animencoder.c:44:9: warning: (near initialization for ‘enc_options.anim_params’) [-Wmissing-braces]
> > 
> 
> Odd, GCC 5.3 doesn't complain, at least not when targeting mingw-w64.
> anim_params is a WebPMuxAnimParams struct within the WebPAnimEncoderOptions struct,
> and WebPAnimEncoderOptionsInit() initializes it to default values anyway, so probably
> not an issue.
> 
> In any case, would something like 
> 
> WebPAnimEncoderOptions enc_options = { .anim_params = { 0 }, 0 };

that fixes it, also
WebPAnimEncoderOptions enc_options = { { 0 } };
Fixes it too

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160317/0afadd0c/attachment.sig>


More information about the ffmpeg-devel mailing list