[FFmpeg-devel] [PATCH]lavc/decode: Initialize a return value on get_format() error
Mark Thompson
sw at jkqxz.net
Sun Dec 9 19:54:58 EET 2018
On 06/12/2018 22:27, Carl Eugen Hoyos wrote:
> Hi!
>
> Attached patch silences a clang warning, please comment.
>
> Carl Eugen
>
>
> From 3b5fc2473235410920ca89c7d84654e2ce8fb29d Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> Date: Thu, 6 Dec 2018 23:17:13 +0100
> Subject: [PATCH] lavc/decode: Initialize return value for get_format()
> failure.
>
> Silences a warning:
> libavcodec/decode.c:1378:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
> ---
> libavcodec/decode.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index c89c77c..a32ff2f 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1378,6 +1378,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
> if (i == n) {
> av_log(avctx, AV_LOG_ERROR, "Invalid return from get_format(): "
> "%s not in possible list.\n", desc->name);
> + ret = AV_PIX_FMT_NONE;
> break;
> }
>
> --
> 1.7.10.4
>
LGTM.
I think I'd also be happy with an assert there that this doesn't happen - it's difficult to argue that the user returning a nonsensical value from get_format is anything other than undefined behaviour.
Thanks,
- Mark
More information about the ffmpeg-devel
mailing list