Skip to content

Commit

Permalink
zlib: fix crash when initializing failed
Browse files Browse the repository at this point in the history
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: #14178
Ref: #13098
Backport-PR-URL: #14860
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Sep 19, 2017
1 parent 2a8ef7a commit 5422eb8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class ZCtx : public AsyncWrap {
delete[] dictionary;
ctx->dictionary_ = nullptr;
}
ctx->mode_ = NONE;
ctx->env()->ThrowError("Init error");
}
}
Expand Down

0 comments on commit 5422eb8

Please sign in to comment.