From 38316ff58b4d8cd5b9b7f6be3a7f2660070fc2bb 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 66a6a476a7c7b2..96c0376f895bbc 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -480,6 +480,7 @@ class ZCtx : public AsyncWrap { delete[] dictionary; ctx->dictionary_ = nullptr; } + ctx->mode_ = NONE; ctx->env()->ThrowError("Init error"); } }