avformat/nutdec: Check X in 2nd branch of index reading
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 22 May 2015 22:23:05 +0000 (00:23 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 22 May 2015 22:52:44 +0000 (00:52 +0200)
Prevents read of uninitialized variable

Based on patch by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit ebb0ca3d70465ab6d369a66b2ef43bb059705db8)

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

index 2188066..72a2436 100644 (file)
@@ -706,6 +706,10 @@ static int find_and_decode_index(NUTContext *nut)
                     has_keyframe[n++] = flag;
                 has_keyframe[n++] = !flag;
             } else {
+                if (x <= 1) {
+                    av_log(s, AV_LOG_ERROR, "index: x %"PRIu64" is invalid\n", x);
+                    goto fail;
+                }
                 while (x != 1) {
                     if (n >= syncpoint_count + 1) {
                         av_log(s, AV_LOG_ERROR, "index overflow B\n");