shithub: openh264

Download patch

ref: 33e67427ab3900ef009b8396e4fa7bef21ebb0bb
parent: 452fb868c7e1467a7900dd7623ab8a1b3b6e6efc
parent: 3c4279cdd8a9a7c96e2bad95f3ae178aa9910e50
author: sijchen <sijchen@cisco.com>
date: Thu Oct 23 14:01:20 EDT 2014

Merge pull request #1438 from huili2/EC_crashfix

fix crash bug of sps/pps

--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -543,7 +543,10 @@
     return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
   }
 
-  pPps    = &pCtx->sPpsBuffer[iPpsId];
+  if (pCtx->iOverwriteFlags & OVERWRITE_PPS)
+    pPps    = &pCtx->sPpsBuffer[MAX_PPS_COUNT];
+  else
+    pPps    = &pCtx->sPpsBuffer[iPpsId];
 
   if (pPps->uiNumSliceGroups == 0) {
     WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -552,7 +555,10 @@
   }
 
   if (kbExtensionFlag) {
-    pSubsetSps	= &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+    if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS)
+      pSubsetSps	= &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT];
+    else
+      pSubsetSps	= &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
     pSps		= &pSubsetSps->sSps;
     if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
       WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
@@ -565,7 +571,10 @@
       pCtx->iErrorCode |= dsNoParamSets;
       return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
     }
-    pSps		= &pCtx->sSpsBuffer[pPps->iSpsId];
+    if (pCtx->iOverwriteFlags & OVERWRITE_SPS)
+      pSps		= &pCtx->sSpsBuffer[MAX_SPS_COUNT];
+    else
+      pSps		= &pCtx->sSpsBuffer[pPps->iSpsId];
   }
   pSliceHead->iPpsId = iPpsId;
   pSliceHead->iSpsId = pPps->iSpsId;