[FFmpeg-cvslog] avformat/smacker: fix memleak when avformat_new_stream failed

Steven Liu git at videolan.org
Mon Oct 28 08:28:41 EET 2019


ffmpeg | branch: master | Steven Liu <lq at chinaffmpeg.org> | Thu Oct 10 10:07:54 2019 +0800| [a3655a5cb2abf3bf2c8a2fa596643059de3396e4] | committer: Steven Liu

avformat/smacker: fix memleak when avformat_new_stream failed

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a3655a5cb2abf3bf2c8a2fa596643059de3396e4
---

 libavformat/smacker.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index b5c858aa9b..239894dad0 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -172,8 +172,11 @@ static int smacker_read_header(AVFormatContext *s)
 
     /* init video codec */
     st = avformat_new_stream(s, NULL);
-    if (!st)
+    if (!st) {
+        av_freep(&smk->frm_size);
+        av_freep(&smk->frm_flags);
         return AVERROR(ENOMEM);
+    }
     smk->videoindex = st->index;
     st->codecpar->width = smk->width;
     st->codecpar->height = smk->height;
@@ -195,8 +198,11 @@ static int smacker_read_header(AVFormatContext *s)
         smk->indexes[i] = -1;
         if (smk->rates[i]) {
             ast[i] = avformat_new_stream(s, NULL);
-            if (!ast[i])
+            if (!ast[i]) {
+                av_freep(&smk->frm_size);
+                av_freep(&smk->frm_flags);
                 return AVERROR(ENOMEM);
+            }
             smk->indexes[i] = ast[i]->index;
             ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
             if (smk->aflags[i] & SMK_AUD_BINKAUD) {



More information about the ffmpeg-cvslog mailing list