From 5422eb8d4ecd313c3164d8607e7fa37d1e6fa0b2 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 Backport-PR-URL: https://github.com/nodejs/node/pull/14860 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"); } }