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
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 Aug 12, 2017
1 parent 5ba65f2 commit e79c054
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 @@ -541,6 +541,7 @@ class ZCtx : public AsyncWrap {
delete[] dictionary;
ctx->dictionary_ = nullptr;
}
ctx->mode_ = NONE;
ctx->env()->ThrowError("Init error");
}
}
Expand Down

0 comments on commit e79c054

Please sign in to comment.