]> granicus.if.org Git - libvpx/commitdiff
Prevent decoder from using uninitialized entropy context.
authorAlexander Voronov <avoronov@graphics.cs.msu.ru>
Thu, 11 Dec 2014 17:44:19 +0000 (20:44 +0300)
committerAlexander Voronov <avoronov@graphics.cs.msu.ru>
Thu, 11 Dec 2014 17:44:19 +0000 (20:44 +0300)
If decoding starts with intra-only frame, there is a possibility
of using uninitialized entropy context, what leads to undefined
behavior.

Change-Id: Icbb64b5b1bd1e5de2a4bfa2884e56bc0a20840af

vp9/common/vp9_entropymode.c
vp9/common/vp9_entropymode.h
vp9/decoder/vp9_decodeframe.c

index d7610ed28e4e827c76ad6ae43c829052d5dfb8b4..0edc4f9bae6689bca75ef23c211da2963a6fa08a 100644 (file)
@@ -453,6 +453,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm) {
   vp9_default_coef_probs(cm);
   vp9_init_mode_probs(cm->fc);
   vp9_init_mv_probs(cm);
+  cm->fc->initialized = 1;
 
   if (cm->frame_type == KEY_FRAME ||
       cm->error_resilient_mode || cm->reset_frame_context == 3) {
index 6831d3f8738ffd148be985bca550ce6162413070..6db10806d443806710acac7ecfa99f08596676a5 100644 (file)
@@ -50,6 +50,7 @@ typedef struct frame_contexts {
   struct tx_probs tx_probs;
   vp9_prob skip_probs[SKIP_CONTEXTS];
   nmv_context nmvc;
+  int initialized;
 } FRAME_CONTEXT;
 
 typedef struct {
index 2c5fbacb9b15de3c7b19289970d0429aacdac23f..470b2bae81f5b5e3583c505cd8f4f895fb04ea57 100644 (file)
@@ -1558,6 +1558,10 @@ void vp9_decode_frame(VP9Decoder *pbi,
   vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);
 
   *cm->fc = cm->frame_contexts[cm->frame_context_idx];
+  if (!cm->fc->initialized)
+    vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
+                       "Uninitialized entropy context.");
+
   vp9_zero(cm->counts);
   vp9_zero(xd->dqcoeff);