From a5dd09934478bd6fe8a14c0c75149c2210622d90 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 7 Aug 2017 19:45:29 +0200 Subject: [PATCH] zlib: check cleanup return values --- src/node_zlib.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 07cd526b1ea8b9..505e0acbcb2b43 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -111,16 +111,18 @@ class ZCtx : public AsyncWrap { CHECK(init_done_ && "close before init"); CHECK_LE(mode_, UNZIP); + int status = Z_OK; if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) { - (void)deflateEnd(&strm_); + status = deflateEnd(&strm_); int64_t change_in_bytes = -static_cast(kDeflateContextSize); env()->isolate()->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); } else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW || mode_ == UNZIP) { - (void)inflateEnd(&strm_); + status = inflateEnd(&strm_); int64_t change_in_bytes = -static_cast(kInflateContextSize); env()->isolate()->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); } + CHECK(status == Z_OK || status == Z_DATA_ERROR); mode_ = NONE; if (dictionary_ != nullptr) {