shithub: openh264

Download patch

ref: 9efbef67b9d24aedcbbd170172da40c533b0f615
parent: 256cd0f6109fbe13a470e74119ce1109bb98ec41
parent: 56767f8154f3e1d4d44a5a4426357138d828db23
author: ruil2 <[email protected]>
date: Wed Jan 22 12:44:05 EST 2014

Merge pull request #153 from licaiguo/fix-empty-packets

fix crash caused by empty packets and add more checks -- review request #44

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -479,7 +479,8 @@
   int32_t iPicHeight		= 0;
   int32_t iBitSize		= 0;
   int32_t iErr				= ERR_NONE;
-
+  if (kiSrcLen <= 0)
+    return iErr;
   pBs	     = &pCtx->sBs;	// SBitStringAux instance for non VCL NALs decoding
   iBitSize = (kiSrcLen << 3) - BsGetTrailingBits (pRbsp + kiSrcLen - 1); // convert into bit
   eNalType = pCtx->sCurNalHead.eNalUnitType;
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -403,7 +403,7 @@
 
   iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
 
-  if (iNextMbXyIndex >= kiCountNumMb) {
+  if ((iNextMbXyIndex < 0) || (iNextMbXyIndex >= kiCountNumMb)) {
     WelsLog (pCtx, WELS_LOG_ERROR,
              "WelsDecodeSlice()::iFirstMbInSlice(%d) > pSps->kiTotalMb(%d). ERROR!!! resolution change....\n",
              iNextMbXyIndex, kiCountNumMb);
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -690,7 +690,7 @@
  */
 void_t UpdateMaxPictureResolution (PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight) {
   //any dimension larger than that of current dimension, should modify the max-dimension
-  if (kiCurWidth > pCtx->iMaxWidthInSps || kiCurHeight > pCtx->iMaxHeightInSps) {
+  if ((kiCurWidth * kiCurHeight) > (pCtx->iMaxWidthInSps * pCtx->iMaxHeightInSps)) {
     pCtx->iMaxWidthInSps	= kiCurWidth;
     pCtx->iMaxHeightInSps	= kiCurHeight;
   }