[FFmpeg-devel] [PATCH] tests/api/api-h264-test: Add proper error handling to avoid potential memory leaks

Michael Niedermayer michael at niedermayer.cc
Mon Aug 11 23:55:06 EEST 2025


On Fri, Aug 08, 2025 at 07:22:29PM +0000, Jiasheng Jiang wrote:
[...]
> @@ -69,44 +70,49 @@ static int video_decode_example(const char *input_filename)
>      codec = avcodec_find_decoder(origin_par->codec_id);
>      if (!codec) {
>          av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
> -        return -1;
> +        result = -1;
> +        goto cloce_fmt_ctx;
>      }
>  
>      ctx = avcodec_alloc_context3(codec);
>      if (!ctx) {
>          av_log(NULL, AV_LOG_ERROR, "Can't allocate decoder context\n");
> -        return AVERROR(ENOMEM);
> +        result = AVERROR(ENOMEM);
> +        goto free_fmt_ctx;


make -j32  fate-api-h264
CC	tests/api/api-h264-test.o
tests/api/api-h264-test.c: In function ‘video_decode_example’:
tests/api/api-h264-test.c:81:9: error: label ‘free_fmt_ctx’ used but not defined
   81 |         goto free_fmt_ctx;
      |         ^~~~
make: *** [ffbuild/common.mak:81: tests/api/api-h264-test.o] Error 1

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

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250811/4d6fce81/attachment.sig>


More information about the ffmpeg-devel mailing list