Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-02-01 15:33:29 +0300
committerAnna Henningsen <anna@addaleax.net>2020-02-05 17:51:31 +0300
commitc1da4e4aa4583c14f87c8d230ce7580f3b157ff0 (patch)
tree3ada9de914da79d4fc4f0526fe40c102c181c393 /src/handle_wrap.h
parent234de6f1fd90ece1edc1a12d989ab0f15a1f19b8 (diff)
src: fix inspecting `MessagePort` from `init` async hook
During the `init()` async hook, the C++ object is not finished creating yet (i.e. it is an `AsyncWrap`, but not yet a `HandleWrap` or `MessagePort`). Accessing the `handle_` field is not valid in that case. However, the custom inspect function for `MessagePort`s calls `HasRef()` on the object, which would crash when the object is not fully constructed. Fix that by guarding the access of the libuv handle on that condition. PR-URL: https://github.com/nodejs/node/pull/31600 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'src/handle_wrap.h')
-rw-r--r--src/handle_wrap.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/handle_wrap.h b/src/handle_wrap.h
index 612874aa2ef..a555da9479d 100644
--- a/src/handle_wrap.h
+++ b/src/handle_wrap.h
@@ -61,7 +61,9 @@ class HandleWrap : public AsyncWrap {
static void HasRef(const v8::FunctionCallbackInfo<v8::Value>& args);
static inline bool IsAlive(const HandleWrap* wrap) {
- return wrap != nullptr && wrap->state_ != kClosed;
+ return wrap != nullptr &&
+ wrap->IsDoneInitializing() &&
+ wrap->state_ != kClosed;
}
static inline bool HasRef(const HandleWrap* wrap) {