summaryrefslogtreecommitdiff
path: root/src/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compress.c')
-rw-r--r--src/compress.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compress.c b/src/compress.c
index 3137145..71e0ae3 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -65,10 +65,13 @@ struct stream *stream_inflate(struct stream *s, size_t len,
/* Deflates `s` into a newly allocated stream structure. */
struct stream *stream_deflate(struct stream *s, size_t len) {
struct stream *new = stream_new(len);
- z_stream strm;
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
+ if (new == NULL)
+ return NULL;
+
+ z_stream strm;
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
if (deflateInit(&strm, LEVEL) != Z_OK)
return NULL;