From: Sen Huang Date: Mon, 4 Nov 2019 19:33:52 +0000 (-0500) Subject: Change to heap allocation, remove implicit type conversion X-Git-Tag: v1.4.5^2~157^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97b7f712f3590bf6b81d2211c6a5f65f81b22ae4;p=thirdparty%2Fzstd.git Change to heap allocation, remove implicit type conversion --- diff --git a/lib/dictBuilder/zdict.c b/lib/dictBuilder/zdict.c index 863a8edf7..32f863660 100644 --- a/lib/dictBuilder/zdict.c +++ b/lib/dictBuilder/zdict.c @@ -104,10 +104,11 @@ size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize) { if (dictSize <= 8 || MEM_readLE32(dictBuffer) != ZSTD_MAGIC_DICTIONARY) return 0; - { ZSTD_entropyDTables_t dummyEntropyTables; - size_t headerSize; - dummyEntropyTables.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); - headerSize = ZSTD_loadDEntropy(&dummyEntropyTables, dictBuffer, dictSize); + { size_t headerSize; + ZSTD_entropyDTables_t* dummyEntropyTables = (ZSTD_entropyDTables_t*)malloc(sizeof(ZSTD_entropyDTables_t)); + dummyEntropyTables->hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); + headerSize = ZSTD_loadDEntropy(dummyEntropyTables, dictBuffer, dictSize); + free(dummyEntropyTables); return ZSTD_isError(headerSize) ? 0 : headerSize; } } diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 9be92471e..9a05daab7 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1137,7 +1137,7 @@ static int basicUnitTests(U32 const seed, double compressibility) size_t* const samplesSizes = (size_t*) malloc(nbSamples * sizeof(size_t)); size_t dictSize; U32 dictID; - U32 dictHeaderSize; + size_t dictHeaderSize; if (dictBuffer==NULL || samplesSizes==NULL) { free(dictBuffer);