From 24219847271f4a2a3a880e67c239124a1a1133f6 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/14673 Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- 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 0793aca1d94cfa..b66313f179cdaa 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) {