shithub: openh264

Download patch

ref: b7bee7af0aa27571f0cd88f94fda9910ca64a32d
parent: 6854e06796aa285c4d22f0e10489d511f9e5f9e2
author: Licai Guo <[email protected]>
date: Sun Feb 23 19:09:40 EST 2014

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 {