Browse Source

zlib: fix crash when initializing failed

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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
v6.x
Anna Henningsen 8 years ago
committed by Myles Borins
parent
commit
e79c054f76
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 1
      src/node_zlib.cc

1
src/node_zlib.cc

@ -541,6 +541,7 @@ class ZCtx : public AsyncWrap {
delete[] dictionary; delete[] dictionary;
ctx->dictionary_ = nullptr; ctx->dictionary_ = nullptr;
} }
ctx->mode_ = NONE;
ctx->env()->ThrowError("Init error"); ctx->env()->ThrowError("Init error");
} }
} }

Loading…
Cancel
Save