PR #23489 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23489
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23489.patch

# Summary of changes

Fix memleak on error paths.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 5e6f05b425d60242100e04f28b3e61055af0cb03 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Mon, 15 Jun 2026 16:51:52 +0800
Subject: [PATCH] avcodec/itut35: free HDR metadata on failure

---
 libavcodec/itut35.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/itut35.c b/libavcodec/itut35.c
index a7ee5e2977..8debf89ab3 100644
--- a/libavcodec/itut35.c
+++ b/libavcodec/itut35.c
@@ -204,8 +204,10 @@ int ff_itut_t35_parse_payload_to_struct(FFITUTT35 *const 
itut_t35, FFITUTT35Aux
 
             ret = av_dynamic_hdr_plus_from_t35(hdr_plus, itut_t35->payload,
                                                itut_t35->payload_size);
-            if (ret < 0)
+            if (ret < 0) {
+                av_free(hdr_plus);
                 return ret;
+            }
 
             av_buffer_unref(&metadata->hdr_plus);
             metadata->hdr_plus = av_buffer_create((uint8_t *)hdr_plus, size, 
NULL, NULL, 0);
@@ -248,8 +250,10 @@ int ff_itut_t35_parse_payload_to_struct(FFITUTT35 *const 
itut_t35, FFITUTT35Aux
 
             ret = av_dynamic_hdr_smpte2094_app5_from_t35(hdr_smpte2094_app5, 
itut_t35->payload,
                                                          
itut_t35->payload_size);
-            if (ret < 0)
+            if (ret < 0) {
+                av_free(hdr_smpte2094_app5);
                 return ret;
+            }
 
             av_buffer_unref(&metadata->hdr_smpte2094_app5);
             metadata->hdr_smpte2094_app5 = av_buffer_create((uint8_t 
*)hdr_smpte2094_app5, size, NULL, NULL, 0);
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to