Skip to content

Commit

Permalink
Better way to fix oss-fuzz reported bug 14267 by re-assigning referen…
Browse files Browse the repository at this point in the history
…ce's references after memory reallocations in DecreasePicBuff instead of just reset.
  • Loading branch information
xiaotiansf committed Apr 21, 2019
1 parent 1f1db72 commit 84b5847
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions codec/decoder/core/src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,24 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
iDelIdx = kiNewSize;
}

//remove references
//update references due to allocation changes
for (int32_t i = 0; i < kiNewSize; i++) {
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
uint32_t j = 0;
while (j < MAX_DPB_COUNT && pPicNewBuf->ppPic[i]->pRefPic[listIdx][j]) {
pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = 0;
++j;
for (int32_t j = 0; j < MAX_DPB_COUNT; j++) {
if (pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] != NULL) {
unsigned long long uiTimeStamp = pPicNewBuf->ppPic[i]->pRefPic[listIdx][j]->uiTimeStamp;
bool foundThePic = false;
for (int32_t k = 0; k < kiNewSize; k++) {
if (pPicNewBuf->ppPic[k]->uiTimeStamp == uiTimeStamp) {
pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = pPicNewBuf->ppPic[k];
foundThePic = true;
break;
}
}
if (!foundThePic) {
pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = NULL;
}
}
}
}
}
Expand Down

0 comments on commit 84b5847

Please sign in to comment.