Fix static analyze error, use proper bounds for dictEnd
This commit is contained in:
parent
d06b90692b
commit
d9c475f3b3
@ -2772,8 +2772,9 @@ size_t ZSTD_loadCEntropy(ZSTD_compressedBlockState_t* bs, void* workspace,
|
|||||||
short* offcodeNCount, unsigned* offcodeMaxValue,
|
short* offcodeNCount, unsigned* offcodeMaxValue,
|
||||||
const void* const dict, size_t dictSize)
|
const void* const dict, size_t dictSize)
|
||||||
{
|
{
|
||||||
const BYTE* dictPtr = (const BYTE*)dict + 8; /* skip magic num and dict ID */
|
const BYTE* dictPtr = (const BYTE*)dict; /* skip magic num and dict ID */
|
||||||
const BYTE* const dictEnd = dictPtr + dictSize;
|
const BYTE* const dictEnd = dictPtr + dictSize;
|
||||||
|
dictPtr += 8;
|
||||||
|
|
||||||
{ unsigned maxSymbolValue = 255;
|
{ unsigned maxSymbolValue = 255;
|
||||||
size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)bs->entropy.huf.CTable, &maxSymbolValue, dictPtr, dictEnd-dictPtr);
|
size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)bs->entropy.huf.CTable, &maxSymbolValue, dictPtr, dictEnd-dictPtr);
|
||||||
|
@ -107,14 +107,15 @@ size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize)
|
|||||||
{ size_t headerSize;
|
{ size_t headerSize;
|
||||||
unsigned offcodeMaxValue = MaxOff;
|
unsigned offcodeMaxValue = MaxOff;
|
||||||
ZSTD_compressedBlockState_t* bs = (ZSTD_compressedBlockState_t*)malloc(sizeof(ZSTD_compressedBlockState_t));
|
ZSTD_compressedBlockState_t* bs = (ZSTD_compressedBlockState_t*)malloc(sizeof(ZSTD_compressedBlockState_t));
|
||||||
|
if (!bs) return ERROR(memory_allocation);
|
||||||
U32* wksp = (U32*)malloc(HUF_WORKSPACE_SIZE);
|
U32* wksp = (U32*)malloc(HUF_WORKSPACE_SIZE);
|
||||||
|
if (!wksp) return ERROR(memory_allocation);
|
||||||
short* offcodeNCount = (short*)malloc((MaxOff+1)*sizeof(short));
|
short* offcodeNCount = (short*)malloc((MaxOff+1)*sizeof(short));
|
||||||
if (!bs || !wksp || !offcodeNCount) {
|
if (!offcodeNCount) return ERROR(memory_allocation);
|
||||||
return ERROR(memory_allocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSTD_reset_compressedBlockState(bs);
|
ZSTD_reset_compressedBlockState(bs);
|
||||||
headerSize = ZSTD_loadCEntropy(bs, wksp, offcodeNCount, &offcodeMaxValue, dictBuffer, dictSize);
|
headerSize = ZSTD_loadCEntropy(bs, wksp, offcodeNCount, &offcodeMaxValue, dictBuffer, dictSize);
|
||||||
|
|
||||||
free(bs);
|
free(bs);
|
||||||
free(wksp);
|
free(wksp);
|
||||||
free(offcodeNCount);
|
free(offcodeNCount);
|
||||||
|
Loading…
Reference in New Issue
Block a user