summaryrefslogtreecommitdiff
path: root/src/node_zlib.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-11-06 22:03:08 +0300
committerBert Belder <bertbelder@gmail.com>2015-01-10 22:32:12 +0100
commit0d02515d6eb2d57cb602b3924c950936f9745adc (patch)
treefb174ae5ce7e529148710f06995c3c68b7193e70 /src/node_zlib.cc
parent4481cf72965eab2a819ef133af8e94fd42f71ae0 (diff)
downloadandroid-node-v8-0d02515d6eb2d57cb602b3924c950936f9745adc.tar.gz
android-node-v8-0d02515d6eb2d57cb602b3924c950936f9745adc.tar.bz2
android-node-v8-0d02515d6eb2d57cb602b3924c950936f9745adc.zip
zlib: do not unref() if wasn't ref()ed
In very unlikely case, where `deflateInit2()` may return error (right now happening only on exhausting all memory), the `ZCtx::Error()` will be called and will try to `Unref()` the handle. But the problem is that this handle was never `Ref()`ed, so it will trigger an assertion error and crash the program. Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/joyent/node/pull/8687 Cherry-picked-from: https://github.com/joyent/node/commit/8c868989be778246bc4b9558f087d0f93724b83d
Diffstat (limited to 'src/node_zlib.cc')
-rw-r--r--src/node_zlib.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index 81fab800aa..e72c29ef07 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -358,8 +358,9 @@ class ZCtx : public AsyncWrap {
ctx->MakeCallback(env->onerror_string(), ARRAY_SIZE(args), args);
// no hope of rescue.
+ if (ctx->write_in_progress_)
+ ctx->Unref();
ctx->write_in_progress_ = false;
- ctx->Unref();
if (ctx->pending_close_)
ctx->Close();
}