From 1a7df525f6c2ea0287351dfad4580d57d23ff730 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 10 Apr 2023 22:12:13 -0300 Subject: [PATCH] avformat/matroskaenc: fix memory leak in fail codepath Signed-off-by: James Almer --- libavformat/matroskaenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 59ed5be951..492b86b8d7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2715,7 +2715,7 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, ret = av_dynamic_hdr_plus_to_t35((AVDynamicHDRPlus *)side_data, &payload, &payload_size); if (ret < 0) - return ret; + goto fail; mkv_write_blockadditional(&writer, buf, buf_size, MATROSKA_BLOCK_ADD_ID_ITU_T_T35); @@ -2738,6 +2738,7 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, track->last_timestamp - ts); ret = ebml_writer_write(&writer, pb); +fail: av_free(buf); return ret;