vp9/count_segs: fix out of bounds read
authorJames Zern <jzern@google.com>
Fri, 3 May 2013 02:11:28 +0000 (19:11 -0700)
committerJames Zern <jzern@google.com>
Fri, 3 May 2013 02:11:28 +0000 (19:11 -0700)
don't access mi until mi_{row,col} validation has been done

Change-Id: Ie1be052612cfccb2730dff9281c222bca28bf2c6

vp9/encoder/vp9_segmentation.c

index 86af268..c53fff4 100644 (file)
@@ -123,11 +123,12 @@ static void count_segs(VP9_COMP *cpi,
                        int bw, int bh, int mi_row, int mi_col) {
   VP9_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->mb.e_mbd;
-  const int segment_id = mi->mbmi.segment_id;
+  int segment_id;
 
   if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
     return;
 
+  segment_id = mi->mbmi.segment_id;
   xd->mode_info_context = mi;
   set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);