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
path: root/src
diff options
context:
space:
mode:
authorDarshan Sen <raisinten@gmail.com>2022-04-09 09:09:03 +0300
committerGitHub <noreply@github.com>2022-04-09 09:09:03 +0300
commitbe011858446f7ec4b914fd1af2cb7555bd04877b (patch)
tree0897c3bdc35661a4cc5750fd9e7af489ba7ea62d /src
parentdfc2dc8b6565da78d493c44aa836482dd422aeed (diff)
src,inspector: fix empty MaybeLocal crash
Return early when the Inspector StringView to V8 String conversion fails and returns an empty MaybeLocal instead of running the invalid ToLocalChecked() assertion. Fixes: https://github.com/nodejs/node/issues/42407 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/42409 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/inspector_js_api.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc
index e605c1c4d6f..4ebb8acd689 100644
--- a/src/inspector_js_api.cc
+++ b/src/inspector_js_api.cc
@@ -75,10 +75,10 @@ class JSBindingsConnection : public AsyncWrap {
Isolate* isolate = env_->isolate();
HandleScope handle_scope(isolate);
Context::Scope context_scope(env_->context());
- MaybeLocal<String> v8string =
- String::NewFromTwoByte(isolate, message.characters16(),
- NewStringType::kNormal, message.length());
- Local<Value> argument = v8string.ToLocalChecked().As<Value>();
+ Local<Value> argument;
+ if (!String::NewFromTwoByte(isolate, message.characters16(),
+ NewStringType::kNormal,
+ message.length()).ToLocal(&argument)) return;
connection_->OnMessage(argument);
}