shithub: openh264

Download patch

ref: 15bd7dab57752e7a2ecbad766037c76e1a8a2190
parent: c7f1974ef7a4b8e7cd8215c002c776326b0f0ff0
author: Licai Guo <[email protected]>
date: Wed Jan 8 19:28:13 EST 2014

fix crash issue for too big packet size

--- a/codec/decoder/core/inc/wels_const.h
+++ b/codec/decoder/core/inc/wels_const.h
@@ -92,7 +92,7 @@
 #define LAYER_NUM_EXCHANGEABLE	1
 
 #define MAX_NAL_UNIT_NUM_IN_AU	32	// predefined maximal number of NAL Units in an access unit
-#define MAX_ACCESS_UINT_CAPACITY	1048576	// Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
+#define MAX_ACCESS_UNIT_CAPACITY	1048576	// Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
 
 enum {
   BASE_MB = 0,
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -303,13 +303,13 @@
   if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU) != 0)
     return ERR_INFO_OUT_OF_MEMORY;
 
-  if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (MAX_ACCESS_UINT_CAPACITY,
+  if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (MAX_ACCESS_UNIT_CAPACITY,
                               "pCtx->sRawData->pHead"))) == NULL) {
     return ERR_INFO_OUT_OF_MEMORY;
   }
   pCtx->sRawData.pStartPos               =
     pCtx->sRawData.pCurPos                 = pCtx->sRawData.pHead;
-  pCtx->sRawData.pEnd                     = pCtx->sRawData.pHead + MAX_ACCESS_UINT_CAPACITY;
+  pCtx->sRawData.pEnd                     = pCtx->sRawData.pHead + MAX_ACCESS_UNIT_CAPACITY;
 
   pCtx->uiTargetDqId			= (uint8_t) - 1;
   pCtx->bEndOfStreamFlag	= false;
@@ -1968,4 +1968,4 @@
   return ERR_NONE;
 }
 
-} // namespace WelsDec
\ No newline at end of file
+} // namespace WelsDec
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -344,6 +344,13 @@
     const int kiSrcLen,
     void_t** ppDst,
     SBufferInfo* pDstInfo) {
+  if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY) {
+    m_pDecContext->iErrorCode |= dsOutOfMemory;
+    IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO,
+      "max AU size exceeded. Allowed size = %d, current size = %d",
+      MAX_ACCESS_UNIT_CAPACITY, kiSrcLen);
+    return dsOutOfMemory;
+  }
   if (kiSrcLen > 0 && kpSrc != NULL) {
 #ifdef OUTPUT_BIT_STREAM
     if (m_pFBS) {