]> granicus.if.org Git - libvpx/commitdiff
Prevent invalid read m52-2743
authorYaowu Xu <yaowu@google.com>
Wed, 18 May 2016 00:18:26 +0000 (17:18 -0700)
committerJohann <johannkoenig@google.com>
Mon, 18 Jul 2016 18:29:59 +0000 (11:29 -0700)
This commit adds a check before reading into RefBuffer to prevent OOB
read.

BUG=https://bugs.chromium.org/p/chromium/issues/detail?id=612023

(cherry picked from commit 4f0e4d6cef827bc452848e126a6bedc47424da88)

Change-Id: I4f0732d4ca92f79b57103bffcff15499073e79a4

vp9/decoder/vp9_decodeframe.c

index 84c757cc7dc4e8d2e856a902fee3a664b487b371..e1453f87f5c07e8ee4dd522a9f5cd9cdd9826511 100644 (file)
@@ -1315,11 +1315,16 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
   BufferPool *const pool = cm->buffer_pool;
   for (i = 0; i < REFS_PER_FRAME; ++i) {
     if (vpx_rb_read_bit(rb)) {
-      YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf;
-      width = buf->y_crop_width;
-      height = buf->y_crop_height;
-      found = 1;
-      break;
+      if (cm->frame_refs[i].idx != INVALID_IDX) {
+        YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf;
+        width = buf->y_crop_width;
+        height = buf->y_crop_height;
+        found = 1;
+        break;
+      } else {
+        vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
+                           "Failed to decode frame size");
+      }
     }
   }