From 1e569f42b6950bfc24b9edaa135abc5b7a79d7f6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 7 Aug 2017 17:12:11 +0200 Subject: [PATCH] zlib: fix crash when initializing failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unset `mode_` when initializing the zlib stream failed, so that we don’t try to call the zlib end functions (`deflateEnd()` etc.) when cleaning up in `ZCtx::Close()`. Fixes: https://github.com/nodejs/node/issues/14178 Ref: https://github.com/nodejs/node/pull/13098 PR-URL: https://github.com/nodejs/node/pull/14666 Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Alexey Orlenko --- src/node_zlib.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 07cd526b1ea8b9..0793aca1d94cfa 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -557,6 +557,7 @@ class ZCtx : public AsyncWrap { delete[] dictionary; ctx->dictionary_ = nullptr; } + ctx->mode_ = NONE; ctx->env()->ThrowError("Init error"); }