Fix corner cases exposed by zstreamtest
This commit is contained in:
parent
94c77710a9
commit
4b92574feb
@ -456,11 +456,11 @@ static int ZSTDMT_serialState_reset(serialState_t* serialState, ZSTDMT_seqPool*
|
|||||||
ZSTD_window_clear(&serialState->ldmState.window);
|
ZSTD_window_clear(&serialState->ldmState.window);
|
||||||
serialState->ldmWindow = serialState->ldmState.window;
|
serialState->ldmWindow = serialState->ldmState.window;
|
||||||
/* Resize tables and output space if necessary. */
|
/* Resize tables and output space if necessary. */
|
||||||
if (serialState->params.ldmParams.hashLog < hashLog) {
|
if (serialState->ldmState.hashTable == NULL || serialState->params.ldmParams.hashLog < hashLog) {
|
||||||
ZSTD_free(serialState->ldmState.hashTable, cMem);
|
ZSTD_free(serialState->ldmState.hashTable, cMem);
|
||||||
serialState->ldmState.hashTable = (ldmEntry_t*)ZSTD_malloc(hashSize, cMem);
|
serialState->ldmState.hashTable = (ldmEntry_t*)ZSTD_malloc(hashSize, cMem);
|
||||||
}
|
}
|
||||||
if (prevBucketLog < bucketLog) {
|
if (serialState->ldmState.bucketOffsets == NULL || prevBucketLog < bucketLog) {
|
||||||
ZSTD_free(serialState->ldmState.bucketOffsets, cMem);
|
ZSTD_free(serialState->ldmState.bucketOffsets, cMem);
|
||||||
serialState->ldmState.bucketOffsets = (BYTE*)ZSTD_malloc(bucketSize, cMem);
|
serialState->ldmState.bucketOffsets = (BYTE*)ZSTD_malloc(bucketSize, cMem);
|
||||||
}
|
}
|
||||||
@ -1591,6 +1591,9 @@ static int ZSTDMT_isOverlapped(buffer_t buffer, range_t range)
|
|||||||
|
|
||||||
if (rangeStart == NULL || bufferStart == NULL)
|
if (rangeStart == NULL || bufferStart == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
/* Empty ranges cannot overlap */
|
||||||
|
if (bufferStart == bufferEnd || rangeStart == rangeEnd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return bufferStart < rangeEnd && rangeStart < bufferEnd;
|
return bufferStart < rangeEnd && rangeStart < bufferEnd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user