Merge pull request #964 from sigiesec/fix-ubsan-resetStreamHC_fast

Don't trigger UBSan warning in LZ4_resetStreamHC_fast if LZ4_streamHC…
This commit is contained in:
Yann Collet 2021-01-19 02:54:18 -08:00 committed by GitHub
commit a8e888774a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1031,7 +1031,11 @@ void LZ4_resetStreamHC_fast (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLev
LZ4_initStreamHC(LZ4_streamHCPtr, sizeof(*LZ4_streamHCPtr));
} else {
/* preserve end - base : can trigger clearTable's threshold */
LZ4_streamHCPtr->internal_donotuse.end -= (uptrval)LZ4_streamHCPtr->internal_donotuse.base;
if (LZ4_streamHCPtr->internal_donotuse.end != NULL) {
LZ4_streamHCPtr->internal_donotuse.end -= (uptrval)LZ4_streamHCPtr->internal_donotuse.base;
} else {
assert(LZ4_streamHCPtr->internal_donotuse.base == NULL);
}
LZ4_streamHCPtr->internal_donotuse.base = NULL;
LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL;
}