shithub: openh264

Download patch

ref: b647a78bf2b046e79cf5d3598520facf60073d12
parent: 6854e06796aa285c4d22f0e10489d511f9e5f9e2
parent: b7bee7af0aa27571f0cd88f94fda9910ca64a32d
author: huili2 <[email protected]>
date: Mon Feb 24 11:21:11 EST 2014

Merge pull request #344 from licaiguo/fix-level-check

refine level check

--- a/codec/decoder/core/inc/error_code.h
+++ b/codec/decoder/core/inc/error_code.h
@@ -133,6 +133,7 @@
   ERR_INFO_INVALID_CBP,
   ERR_INFO_DQUANT_OUT_OF_RANGE,
   ERR_INFO_CAVLC_INVALID_PREFIX,
+  ERR_INFO_CAVLC_INVALID_LEVEL,
   ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES,
   ERR_INFO_CAVLC_INVALID_ZERO_LEFT,
   ERR_INFO_CAVLC_INVALID_RUN_BEFORE,
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -718,8 +718,10 @@
   if ((uiTrailingOnes > 3) || (uiTotalCoeff > 16)) { /////////////////check uiTrailingOnes and uiTotalCoeff
     return ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES;
   }
-  iUsedBits += CavlcGetLevelVal (iLevel, &sReadBitsCache, uiTotalCoeff, uiTrailingOnes);
-
+  if ((i = CavlcGetLevelVal (iLevel, &sReadBitsCache, uiTotalCoeff, uiTrailingOnes)) == -1) {
+    return ERR_INFO_CAVLC_INVALID_LEVEL;
+  }
+  iUsedBits += i;
   if (uiTotalCoeff < iMaxNumCoeff) {
     iUsedBits += CavlcGetTotalZeros (iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
   } else {