Skip to content

Commit bdb850d

Browse files
committed
Merge pull request #1873 from huili2/fix_1145964_v14
fix order of null pointer protection
2 parents 52cb8c1 + d3ff712 commit bdb850d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

codec/decoder/core/src/decoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
426426

427427
if (pCtx->pCabacDecEngine == NULL)
428428
pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
429-
429+
WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
430430
return ERR_NONE;
431431
}
432432

codec/decoder/core/src/decoder_core.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,6 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
12651265
int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]");
12661266
pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
12671267
"pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010
1268-
if (pCtx->sMb.pSliceIdc[i] != NULL)
1269-
memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
12701268
pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12711269
"pCtx->sMb.pResidualPredFlag[]");
12721270
//pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]");
@@ -1303,6 +1301,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
13031301
)
13041302
)
13051303

1304+
memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
1305+
13061306
pCtx->pDqLayersList[i] = pDq;
13071307
++ i;
13081308
} while (i < LAYER_NUM_EXCHANGEABLE);

codec/decoder/core/src/pic_queue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
9090
} else {
9191
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */
9292
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
93-
memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
94-
9593
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
94+
95+
memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
9696
pPic->iLinesize[0] = iPicWidth;
9797
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
9898
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;

0 commit comments

Comments
 (0)