diff mbox series

[FFmpeg-devel,2/8] avformat/ipmovie: Free packets allocated in header reading

Message ID 20210201223116.11378-2-michael@niedermayer.cc
State Accepted
Commit 712d3ac539f30239b764d8621829dc9dc913da61
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs_sei_syntax_template: Check for non negativity before setting size_t bits_left | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Feb. 1, 2021, 10:31 p.m. UTC
Fixes: memleaks
Fixes: 29905/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5679700745781248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/ipmovie.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer March 15, 2021, 9:07 p.m. UTC | #1
On Mon, Feb 01, 2021 at 11:31:10PM +0100, Michael Niedermayer wrote:
> Fixes: memleaks
> Fixes: 29905/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5679700745781248
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/ipmovie.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 137c857700..3234d591da 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -661,8 +661,10 @@  static int ipmovie_read_header(AVFormatContext *s)
         ipmovie->palette[i] = 0xFFU << 24;
 
     /* process the first chunk which should be CHUNK_INIT_VIDEO */
-    if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
+    if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO) {
+        av_packet_unref(&pkt);
         return AVERROR_INVALIDDATA;
+    }
 
     /* peek ahead to the next chunk-- if it is an init audio chunk, process
      * it; if it is the first video chunk, this is a silent file */
@@ -674,8 +676,10 @@  static int ipmovie_read_header(AVFormatContext *s)
 
     if (chunk_type == CHUNK_VIDEO)
         ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
-    else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
+    else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO) {
+        av_packet_unref(&pkt);
         return AVERROR_INVALIDDATA;
+    }
 
     /* initialize the stream decoders */
     st = avformat_new_stream(s, NULL);