]> granicus.if.org Git - libvpx/commitdiff
Prevent invaid memory access
authorYaowu Xu <yaowu@google.com>
Wed, 22 Jan 2014 17:10:44 +0000 (09:10 -0800)
committerYaowu Xu <yaowu@google.com>
Wed, 22 Jan 2014 17:10:44 +0000 (09:10 -0800)
Reading second motion vector only when it has a second ref_frame

Change-Id: Ica72c1cd955832e15ceccda5e5a17b0bfcd83044

vp9/encoder/vp9_encodeframe.c

index 9966cb6ae751bfe9e549eb4073a35ccf1571e93c..9d02c8f95cc73093ba6d3c76a6a2073260d7c6c0 100644 (file)
@@ -500,7 +500,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
     if (is_inter_block(mbmi) &&
         (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV)) {
       int_mv best_mv[2];
-      for (i = 0; i < 2; ++i)
+      for (i = 0; i < 1 + has_second_ref(mbmi); ++i)
         best_mv[i].as_int = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_int;
       vp9_update_mv_count(cpi, x, best_mv);
     }