Fix use of uninitialized memory in 4X Technologies demuxer.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 1 Oct 2011 22:38:26 +0000 (00:38 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 1 Oct 2011 23:02:29 +0000 (01:02 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/4xm.c

index cd4066d..f535c49 100644 (file)
@@ -173,14 +173,16 @@ static int fourxm_read_header(AVFormatContext *s,
                 goto fail;
             }
             if (current_track + 1 > fourxm->track_count) {
-                fourxm->track_count = current_track + 1;
                 fourxm->tracks = av_realloc_f(fourxm->tracks,
                                               sizeof(AudioTrack),
-                                              fourxm->track_count);
+                                              current_track + 1);
                 if (!fourxm->tracks) {
                     ret=  AVERROR(ENOMEM);
                     goto fail;
                 }
+                memset(&fourxm->tracks[fourxm->track_count], 0,
+                       sizeof(AudioTrack) * (current_track + 1 - fourxm->track_count));
+                fourxm->track_count = current_track + 1;
             }
             fourxm->tracks[current_track].adpcm       = AV_RL32(&header[i + 12]);
             fourxm->tracks[current_track].channels    = AV_RL32(&header[i + 36]);