mirror of
https://github.com/facebook/zstd.git
synced 2025-12-04 00:04:23 -05:00
Checks malloc() for failure, returns 0 if so
This commit is contained in:
parent
97b7f712f3
commit
341e0641ed
@ -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);
|
||||
|
||||
@ -64,7 +64,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
|
||||
|
||||
/*====== Helper functions ======*/
|
||||
ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
|
||||
ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns zero if error (not a valid dictionary) */
|
||||
ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns zero if error (not a valid dictionary or mem alloc failure) */
|
||||
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
||||
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user