Don't trigger UBSan warning in LZ4_resetStreamHC_fast if LZ4_streamHCPtr->internal_donotuse.end is NULL.

This commit is contained in:
Simon Giesecke 2021-01-07 10:21:48 +01:00
parent 023bb62c8d
commit 06b07e175e

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;
}