[FFmpeg-devel] [PATCH v1 04/11] avformat/jvdec: fix memleak when read_header failed

Steven Liu lq at chinaffmpeg.org
Wed Oct 9 10:35:23 EEST 2019


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/jvdec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 18c81f0de7..17ada7b0f1 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -113,9 +113,10 @@ static int read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame));
-    if (!jv->frames)
+    if (!jv->frames) {
+        av_freep(&ast->index_entries);
         return AVERROR(ENOMEM);
-
+    }
     offset = 0x68 + ast->nb_index_entries * 16;
     for (i = 0; i < ast->nb_index_entries; i++) {
         AVIndexEntry *e   = ast->index_entries + i;
@@ -137,6 +138,8 @@ static int read_header(AVFormatContext *s)
                     - jvf->palette_size < 0) {
             if (s->error_recognition & AV_EF_EXPLODE) {
                 read_close(s);
+                av_freep(&jv->frames);
+                av_freep(&ast->index_entries);
                 return AVERROR_INVALIDDATA;
             }
             jvf->audio_size   =
-- 
2.15.1






More information about the ffmpeg-devel mailing list