shithub: libvpx

Download patch

ref: 04fa2ecdf24a1c9656c37b29c73a0a4a4a4267c0
parent: b8c369053b8baffc2181b7b362262269f9e346e6
author: Adrian Grange <agrange@google.com>
date: Thu May 31 05:51:54 EDT 2012

Fixed bug where invalid pointer is dereferenced

Variables m & mi were being dereferenced when they might
hold invalid values.

The fix is simply to move these dereferences to after the
point at which mb_row and mb_col are tested for validity.

Change-Id: Ib16561efa9792dc469759936189ea379d374ad20

--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -872,10 +872,10 @@
             // top-left, top-right, bottom-left, bottom-right
             for (i=0; i<4; i++)
             {
-                const MB_MODE_INFO *const mi = & m->mbmi;
-                const MV_REFERENCE_FRAME rf = mi->ref_frame;
-                const MB_PREDICTION_MODE mode = mi->mode;
-                const int segment_id = mi->segment_id;
+                MB_MODE_INFO *mi;
+                MV_REFERENCE_FRAME rf;
+                MB_PREDICTION_MODE mode;
+                int segment_id;
 
                 int dy = row_delta[i];
                 int dx = col_delta[i];
@@ -891,6 +891,11 @@
                     cpi->mb.partition_info += offset_extended;
                     continue;
                 }
+
+                mi = & m->mbmi;
+                rf = mi->ref_frame;
+                mode = mi->mode;
+                segment_id = mi->segment_id;
 
                 // Distance of Mb to the various image edges.
                 // These specified to 8th pel as they are always compared to MV
--