[FFmpeg-devel] [PATCH] fix uninitialized variable being used

Reimar Döffinger Reimar.Doeffinger
Sat Feb 2 22:04:23 CET 2008


Hello,
I think in this case gcc guesses right and the code is broken for files
that have samplerate = 0 but contain audio packets.
Those most likely are not "valid" files, but should still be handled
graciously.
Do you agree with my analysis and attached patch?

Greetings,
Reimar D?ffinger
-------------- next part --------------
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index 0f50634..5e68a81 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -73,7 +73,7 @@ static int vmd_read_header(AVFormatContext *s,
 {
     VmdDemuxContext *vmd = s->priv_data;
     ByteIOContext *pb = s->pb;
-    AVStream *st, *vst;
+    AVStream *st = NULL, *vst;
     unsigned int toc_offset;
     unsigned char *raw_frame_table;
     int raw_frame_table_size;
@@ -181,6 +181,7 @@ static int vmd_read_header(AVFormatContext *s,
                 continue;
             switch(type) {
             case 1: /* Audio Chunk */
+                if (!st) break;
                 /* first audio chunk contains several audio buffers */
                 if(current_audio_pts){
                     vmd->frame_table[total_frames].frame_offset = current_offset;



More information about the ffmpeg-devel mailing list