From c6f1ab616e6686917d0451e610fd2533aecc9a5c Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Fri, 10 Apr 2020 12:40:57 +0000 Subject: [PATCH] tight: Replace an assert with return -1 --- src/tight.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tight.c b/src/tight.c index 33e8396..8206a1c 100644 --- a/src/tight.c +++ b/src/tight.c @@ -178,8 +178,6 @@ compress_failure: int tight_deflate(struct vec* dst, void* src, size_t len, z_stream* zs, bool flush) { - int r = Z_STREAM_ERROR; - zs->next_in = src; zs->avail_in = len; @@ -190,8 +188,9 @@ int tight_deflate(struct vec* dst, void* src, size_t len, z_stream* zs, bool flu zs->next_out = ((Bytef*)dst->data) + dst->len; zs->avail_out = dst->cap - dst->len; - r = deflate(zs, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH); - assert(r != Z_STREAM_ERROR); + int r = deflate(zs, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH); + if (r == Z_STREAM_ERROR) + return -1; dst->len = zs->next_out - (Bytef*)dst->data; } while (zs->avail_out == 0);