4xmdemux: prevent use of uninitialized memory
authorLaurent Aimar <fenrir@videolan.org>
Sun, 2 Oct 2011 00:48:11 +0000 (00:48 +0000)
committerJanne Grunau <janne-libav@jannau.net>
Mon, 10 Oct 2011 19:37:35 +0000 (21:37 +0200)
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
libavformat/4xm.c

index 6224134..1557c5b 100644 (file)
@@ -173,13 +173,15 @@ 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(fourxm->tracks,
-                    fourxm->track_count * sizeof(AudioTrack));
+                    (current_track + 1) * sizeof(AudioTrack));
                 if (!fourxm->tracks) {
-                    ret AVERROR(ENOMEM);
+                    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]);