mail: Fix PVS 965
Fix memory leak when realloc() fails. Change-Id: I8f7fb3ce7f43de03f76e8f0ee14277d79a55ee63 Reviewed-on: https://review.haiku-os.org/c/1005 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
6c67c7d635
commit
21392fa9b1
@@ -268,9 +268,14 @@ WIndex::_BlockCheck(void)
|
|||||||
if (fEntries < fMaxEntries)
|
if (fEntries < fMaxEntries)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
fBlocks = fEntries / fEntriesPerBlock + 1;
|
fBlocks = fEntries / fEntriesPerBlock + 1;
|
||||||
fEntryList = (uint8 *)realloc(fEntryList, fBlockSize * fBlocks);
|
uint8* tmpEntryList = (uint8 *)realloc(fEntryList, fBlockSize * fBlocks);
|
||||||
if (!fEntryList)
|
if (!tmpEntryList) {
|
||||||
|
free(fEntryList);
|
||||||
|
fEntryList = NULL;
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
} else {
|
||||||
|
fEntryList = tmpEntryList;
|
||||||
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user