ffmpeg | branch: master | Lidong Yan <yldhome...@gmail.com> | Tue Jun 17 
22:14:15 2025 +0800| [ee1f79b0fa4c82da9c19328b049b593c71611402] | committer: 
James Almer

avformat/sbgdec: fix leak in sbg_read_header()

In sbg_read_header(), if avformat_new_stream() failed, it returns
without cleanup, which may cause memory leaks. Replace return statement
with goto so that we would first clean up then return.

Signed-off-by: Lidong Yan <502024330...@smail.nju.edu.cn>
Reviewed-by: Nicolas George <geo...@nsup.org>
Signed-off-by: James Almer <jamr...@gmail.com>

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

 libavformat/sbgdec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index bf319be228..4afb51b844 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1434,8 +1434,10 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
     }
 
     st = avformat_new_stream(avf, NULL);
-    if (!st)
-        return AVERROR(ENOMEM);
+    if (!st) {
+        r = AVERROR(ENOMEM);
+        goto fail;
+    }
     sti = ffstream(st);
     st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id       = AV_CODEC_ID_FFWAVESYNTH;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to