shithub: openh264

Download patch

ref: 7bace8406eefd5ad172300d1bcaa953e1c31a7c5
parent: 136931c265bbe3a50bea42675adcf3a9ff28e890
author: Licai Guo <[email protected]>
date: Sun Feb 16 19:47:41 EST 2014

remain size to prvent MB residual reading overflow

--- a/codec/decoder/core/inc/wels_const.h
+++ b/codec/decoder/core/inc/wels_const.h
@@ -93,6 +93,7 @@
 
 #define MAX_NAL_UNIT_NUM_IN_AU	32	// predefined maximal number of NAL Units in an access unit
 #define MAX_ACCESS_UNIT_CAPACITY	1048576	// Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
+#define MAX_MACROBLOCK_CAPACITY 5000 //Maximal legal MB capacity, 15000 bits is enough
 
 enum {
   BASE_MB = 0,
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -361,7 +361,7 @@
     const int kiSrcLen,
     void** ppDst,
     SBufferInfo* pDstInfo) {
-  if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY) {
+  if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY - MAX_MACROBLOCK_CAPACITY) {//prevent from residual reading overflow
     m_pDecContext->iErrorCode |= dsOutOfMemory;
     IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO,
       "max AU size exceeded. Allowed size = %d, current size = %d",