[FFmpeg-devel] [PATCH 1/2] libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct
wm4
nfxjfg at googlemail.com
Thu Mar 17 17:20:00 CET 2016
On Thu, 17 Mar 2016 13:15:23 -0300
James Almer <jamrial at gmail.com> 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 };
>
> be better, or is it too ugly? Alternatively i could just memset the whole thing to 0.
You don't need that. Your original patch is perfectly valid C.
More information about the ffmpeg-devel
mailing list