avformat/mp3dec: properly allocate dummy AVCodecContext
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 26 Feb 2015 18:59:44 +0000 (19:59 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 19 May 2015 18:25:10 +0000 (20:25 +0200)
Fixes (harmless) use of uninitialized variable

Found-by: jamrial
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6ad42b3e15478284321dd285acaf189a16590854)

Conflicts:

libavformat/mp3dec.c

libavformat/mp3dec.c

index ea9f2c3..7ad6845 100644 (file)
@@ -61,7 +61,7 @@ static int mp3_read_probe(AVProbeData *p)
     int fsize, frames, sample_rate;
     uint32_t header;
     const uint8_t *buf, *buf0, *buf2, *end;
-    AVCodecContext avctx;
+    AVCodecContext *avctx = avcodec_alloc_context3(NULL);
 
     buf0 = p->buf;
     end = p->buf + p->buf_size - sizeof(uint32_t);
@@ -78,7 +78,7 @@ static int mp3_read_probe(AVProbeData *p)
 
         for(frames = 0; buf2 < end; frames++) {
             header = AV_RB32(buf2);
-            fsize = avpriv_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate);
+            fsize = avpriv_mpa_decode_header(avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate);
             if(fsize < 0)
                 break;
             buf2 += fsize;
@@ -87,6 +87,7 @@ static int mp3_read_probe(AVProbeData *p)
         if(buf == buf0)
             first_frames= frames;
     }
+    avcodec_free_context(&avctx);
     // keep this in sync with ac3 probe, both need to avoid
     // issues with MPEG-files!
     if   (first_frames>=4) return AVPROBE_SCORE_EXTENSION + 1;