Skip to content

Commit

Permalink
zlib: check cleanup return values
Browse files Browse the repository at this point in the history
PR-URL: #14673
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Aug 10, 2017
1 parent cea4bd9 commit 2421984
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(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<int64_t>(kInflateContextSize);
env()->isolate()->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
}
CHECK(status == Z_OK || status == Z_DATA_ERROR);
mode_ = NONE;

if (dictionary_ != nullptr) {
Expand Down

0 comments on commit 2421984

Please sign in to comment.