mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: fix crash in AfterGetAddrInfo
Remove invalid usage of `Check()`. This addresses:
FATAL ERROR: v8::FromJust Maybe value is Nothing.
1: 0x101311bf5 node::Abort() (.cold.1) [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
2: 0x1000ade29 node::Abort() [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
3: 0x1000adf8f node::OnFatalError(char const*, char const*) [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
4: 0x1001f42d0 v8::V8::FromJustIsNothing() [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
5: 0x1000268e2 node::cares_wrap::(anonymous namespace)::AfterGetAddrInfo(uv_getaddrinfo_s*, int, addrinfo*)::$_2::operator()(bool, bool) const [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
6: 0x10002657c node::cares_wrap::(anonymous namespace)::AfterGetAddrInfo(uv_getaddrinfo_s*, int, addrinfo*) [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
7: 0x1009fb388 uv__work_done [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
8: 0x100a00453 uv__async_io [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
9: 0x100a140cc uv__io_poll [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
10: 0x100a009c1 uv_run [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
11: 0x10014aca0 node::worker::Worker::Run() [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
12: 0x10014e56f node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_3::__invoke(void*) [/Users/xxx/.nvm/versions/node/v14.17.4/bin/node]
13: 0x7fff703d42eb _pthread_body [/usr/lib/system/libsystem_pthread.dylib]
14: 0x7fff703d7249 _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
15: 0x7fff703d340d thread_start [/usr/lib/system/libsystem_pthread.dylib]
PR-URL: https://github.com/nodejs/node/pull/39735
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
committed by
James M Snell
parent
3b1e6f202e
commit
1bd1a7ede5
@@ -63,7 +63,10 @@ using v8::HandleScope;
|
||||
using v8::Int32;
|
||||
using v8::Integer;
|
||||
using v8::Isolate;
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
using v8::Nothing;
|
||||
using v8::Null;
|
||||
using v8::Object;
|
||||
using v8::String;
|
||||
@@ -1443,7 +1446,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
|
||||
if (status == 0) {
|
||||
Local<Array> results = Array::New(env->isolate());
|
||||
|
||||
auto add = [&] (bool want_ipv4, bool want_ipv6) {
|
||||
auto add = [&] (bool want_ipv4, bool want_ipv6) -> Maybe<bool> {
|
||||
for (auto p = res; p != nullptr; p = p->ai_next) {
|
||||
CHECK_EQ(p->ai_socktype, SOCK_STREAM);
|
||||
|
||||
@@ -1463,14 +1466,19 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
|
||||
continue;
|
||||
|
||||
Local<String> s = OneByteString(env->isolate(), ip);
|
||||
results->Set(env->context(), n, s).Check();
|
||||
if (results->Set(env->context(), n, s).IsNothing())
|
||||
return Nothing<bool>();
|
||||
n++;
|
||||
}
|
||||
return Just(true);
|
||||
};
|
||||
|
||||
add(true, verbatim);
|
||||
if (verbatim == false)
|
||||
add(false, true);
|
||||
if (add(true, verbatim).IsNothing())
|
||||
return;
|
||||
if (verbatim == false) {
|
||||
if (add(false, true).IsNothing())
|
||||
return;
|
||||
}
|
||||
|
||||
// No responses were found to return
|
||||
if (n == 0) {
|
||||
|
||||
Reference in New Issue
Block a user