[FFmpeg-devel] [PATCH 1/3] avcodec/h264_metadata: fix memory leak in case of output packet creation failure

James Almer jamrial at gmail.com
Tue Mar 20 05:55:26 EET 2018


Some function calls may fail after the output packet is initialized.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/h264_metadata_bsf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index e1f0c43b71..0381e9d102 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -545,6 +545,8 @@ fail:
     ff_cbs_fragment_uninit(ctx->cbc, au);
     av_freep(&displaymatrix_side_data);
 
+    if (err < 0)
+        av_packet_unref(&out);
     av_packet_free(&in);
 
     return err;
-- 
2.16.2



More information about the ffmpeg-devel mailing list