avformat/bink: Check return value of av_add_index_entry()
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 17 Feb 2014 22:44:49 +0000 (23:44 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 23 Feb 2014 14:03:03 +0000 (15:03 +0100)
Fixes null pointer dereference
Fixes: cdbf15cbd0a27cee958dd0b8800e452e-signal_sigsegv_737991_2083_cov_317652874_LBSTART.BIK
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit c57fc97e956a52edc94a38ff0ecd3058b44c15b7)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/bink.c

index 6db73cc..b9c853c 100644 (file)
@@ -79,6 +79,7 @@ static int read_header(AVFormatContext *s)
     uint32_t pos, next_pos;
     uint16_t flags;
     int keyframe;
+    int ret;
 
     vst = avformat_new_stream(s, NULL);
     if (!vst)
@@ -177,8 +178,9 @@ static int read_header(AVFormatContext *s)
             av_log(s, AV_LOG_ERROR, "invalid frame index table\n");
             return AVERROR(EIO);
         }
-        av_add_index_entry(vst, pos, i, next_pos - pos, 0,
-                           keyframe ? AVINDEX_KEYFRAME : 0);
+        if ((ret = av_add_index_entry(vst, pos, i, next_pos - pos, 0,
+                                      keyframe ? AVINDEX_KEYFRAME : 0)) < 0)
+            return ret;
     }
 
     avio_skip(pb, 4);