Skip to content

Commit 2421984

Browse files
committed
zlib: check cleanup return values
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]>
1 parent cea4bd9 commit 2421984

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node_zlib.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,18 @@ class ZCtx : public AsyncWrap {
111111
CHECK(init_done_ && "close before init");
112112
CHECK_LE(mode_, UNZIP);
113113

114+
int status = Z_OK;
114115
if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) {
115-
(void)deflateEnd(&strm_);
116+
status = deflateEnd(&strm_);
116117
int64_t change_in_bytes = -static_cast<int64_t>(kDeflateContextSize);
117118
env()->isolate()->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
118119
} else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW ||
119120
mode_ == UNZIP) {
120-
(void)inflateEnd(&strm_);
121+
status = inflateEnd(&strm_);
121122
int64_t change_in_bytes = -static_cast<int64_t>(kInflateContextSize);
122123
env()->isolate()->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
123124
}
125+
CHECK(status == Z_OK || status == Z_DATA_ERROR);
124126
mode_ = NONE;
125127

126128
if (dictionary_ != nullptr) {

0 commit comments

Comments
 (0)