]> git.sesse.net Git - ffmpeg/commitdiff
avformat/rl2: fix memleak when read end of file
authorSteven Liu <lq@chinaffmpeg.org>
Thu, 10 Oct 2019 02:07:52 +0000 (10:07 +0800)
committerSteven Liu <lq@chinaffmpeg.org>
Mon, 28 Oct 2019 06:26:11 +0000 (14:26 +0800)
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
libavformat/rl2.c

index d847d9aaa88a7e7d036146f26e85b7cd51ba3187..07696965c72c46ca33cb5e135a8089c09a6cbec7 100644 (file)
@@ -171,18 +171,24 @@ static av_cold int rl2_read_header(AVFormatContext *s)
 
     /** read offset and size tables */
     for(i=0; i < frame_count;i++) {
-        if (avio_feof(pb))
-            return AVERROR_INVALIDDATA;
+        if (avio_feof(pb)) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
         chunk_size[i] = avio_rl32(pb);
     }
     for(i=0; i < frame_count;i++) {
-        if (avio_feof(pb))
-            return AVERROR_INVALIDDATA;
+        if (avio_feof(pb)) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
         chunk_offset[i] = avio_rl32(pb);
     }
     for(i=0; i < frame_count;i++) {
-        if (avio_feof(pb))
-            return AVERROR_INVALIDDATA;
+        if (avio_feof(pb)) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
         audio_size[i] = avio_rl32(pb) & 0xFFFF;
     }
 
@@ -203,7 +209,7 @@ static av_cold int rl2_read_header(AVFormatContext *s)
         ++video_frame_counter;
     }
 
-
+end:
     av_free(chunk_size);
     av_free(audio_size);
     av_free(chunk_offset);