Checks malloc() for failure, returns 0 if so

This commit is contained in:
Sen Huang
2019-11-08 13:57:26 -05:00
parent 97b7f712f3
commit 341e0641ed
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -106,6 +106,9 @@ size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize)
{ size_t headerSize;
ZSTD_entropyDTables_t* dummyEntropyTables = (ZSTD_entropyDTables_t*)malloc(sizeof(ZSTD_entropyDTables_t));
if (!dummyEntropyTables) {
return 0;
}
dummyEntropyTables->hufTable[0] = (HUF_DTable)((HufLog)*0x1000001);
headerSize = ZSTD_loadDEntropy(dummyEntropyTables, dictBuffer, dictSize);
free(dummyEntropyTables);