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

# Summary of changes

Fix two memleak case.

<!--
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 7634236a1f78379ce1861df41ca24cb357c218b7 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Thu, 29 Oct 2026 20:34:58 +0800
Subject: [PATCH 1/2] avcodec/lcevcdec: free the option strings of a released
 context

The context owns a copy of every string passed in -lcevc-dec-params, and
lcevc_free() released everything else.

Signed-off-by: Zhao Zhili <[email protected]>
---
 libavcodec/lcevcdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c
index 3e990c0544b..fb9e6878238 100644
--- a/libavcodec/lcevcdec.c
+++ b/libavcodec/lcevcdec.c
@@ -372,6 +372,7 @@ static void lcevc_free(AVRefStructOpaque unused, void *obj)
     av_freep(&lcevc->frag);
     ff_cbs_close(&lcevc->cbc);
     av_refstruct_pool_uninit(&lcevc->frame_pool);
+    av_opt_free(lcevc);
     memset(lcevc, 0, sizeof(*lcevc));
 }
 
-- 
2.54.0


>From 062cfc475ce1823c297502958543a5fdde164cc3 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Thu, 29 Oct 2026 20:34:58 +0800
Subject: [PATCH 2/2] avcodec/lcevcdec: release the context when option parsing
 fails

Signed-off-by: Zhao Zhili <[email protected]>
---
 libavcodec/lcevcdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c
index fb9e6878238..066866a75e9 100644
--- a/libavcodec/lcevcdec.c
+++ b/libavcodec/lcevcdec.c
@@ -606,11 +606,12 @@ int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary 
**options, int loglevel
 
     ret = av_opt_set_dict2(lcevc, options, 0);
     if (ret < 0)
-        return ret;
+        goto fail;
 
     if (t = av_dict_iterate(*options, NULL)) {
         av_log(NULL, AV_LOG_FATAL, "liblcevc-dec option %s not found.\n", 
t->key);
-        return AVERROR_OPTION_NOT_FOUND;
+        ret = AVERROR_OPTION_NOT_FOUND;
+        goto fail;
     }
 
     lcevc->frag = av_mallocz(sizeof(*lcevc->frag));
-- 
2.54.0

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

Reply via email to