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:
Murai Takashi
2019-02-03 18:05:55 +00:00
committed by waddlesplash
parent 6c67c7d635
commit 21392fa9b1
+7 -2
View File
@@ -268,9 +268,14 @@ WIndex::_BlockCheck(void)
if (fEntries < fMaxEntries)
return B_OK;
fBlocks = fEntries / fEntriesPerBlock + 1;
fEntryList = (uint8 *)realloc(fEntryList, fBlockSize * fBlocks);
if (!fEntryList)
uint8* tmpEntryList = (uint8 *)realloc(fEntryList, fBlockSize * fBlocks);
if (!tmpEntryList) {
free(fEntryList);
fEntryList = NULL;
return B_ERROR;
} else {
fEntryList = tmpEntryList;
}
return B_OK;
}