summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-04-08 23:51:22 (GMT)
committerYann Collet <cyan@fb.com>2019-04-08 23:51:22 (GMT)
commit5ef4f3ce913dae19f6bcd065a2b231c5461e4233 (patch)
treeff2ec8e0fef389f477615b354d7f3dfce49cd804 /lib
parent111df0fa45729538cc8ec526c71e854d0f15dc2e (diff)
downloadlz4-5ef4f3ce913dae19f6bcd065a2b231c5461e4233.zip
lz4-5ef4f3ce913dae19f6bcd065a2b231c5461e4233.tar.gz
lz4-5ef4f3ce913dae19f6bcd065a2b231c5461e4233.tar.bz2
check some more initialization result
ensure it's not NULL.
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 04a30e7..5fbc7c7 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1126,6 +1126,7 @@ _failure:
int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration)
{
LZ4_stream_t_internal* const ctx = & LZ4_initStream(state, sizeof(LZ4_stream_t)) -> internal_donotuse;
+ assert(ctx != NULL);
if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
if (maxOutputSize >= LZ4_compressBound(inputSize)) {
if (inputSize < LZ4_64Klimit) {
@@ -1236,7 +1237,8 @@ int LZ4_compress_fast_force(const char* src, char* dst, int srcSize, int dstCapa
* _continue() call without resetting it. */
static int LZ4_compress_destSize_extState (LZ4_stream_t* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize)
{
- LZ4_initStream(state, sizeof (*state));
+ void* const s = LZ4_initStream(state, sizeof (*state));
+ assert(s != NULL); (void)s;
if (targetDstSize >= LZ4_compressBound(*srcSizePtr)) { /* compression success is guaranteed */
return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, 1);
@@ -1307,6 +1309,8 @@ LZ4_stream_t* LZ4_initStream (void* buffer, size_t size)
return (LZ4_stream_t*)buffer;
}
+/* resetStream is now deprecated,
+ * prefer initStream() which is more general */
void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
{
DEBUGLOG(5, "LZ4_resetStream (ctx:%p)", LZ4_stream);