fix crash issue for too big packet size

This commit is contained in:
Licai Guo 2014-01-09 00:28:13 -08:00
parent c7f1974ef7
commit 15bd7dab57
3 changed files with 11 additions and 4 deletions

View File

@ -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,

View File

@ -303,13 +303,13 @@ int32_t WelsInitMemory (PWelsDecoderContext pCtx) {
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 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3
return ERR_NONE;
}
} // namespace WelsDec
} // namespace WelsDec

View File

@ -344,6 +344,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
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) {