Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src,inspector: fix empty MaybeLocal crash #42409

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/inspector_js_api.cc
Expand Up @@ -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);
}

Expand Down
20 changes: 20 additions & 0 deletions test/pummel/test-repl-empty-maybelocal-crash.js
@@ -0,0 +1,20 @@
'use strict';
const common = require('../common');

if (process.config.variables.arm_version === '7') {
common.skip('Too slow for armv7 bots');
}

// The process should not crash when the REPL receives the string, 'ss'.
// Test for https://github.com/nodejs/node/issues/42407.

const repl = require('repl');

const r = repl.start();

r.write('var buf = Buffer.from({length:200e6},(_,i) => i%256);\n');
r.write('var ss = buf.toString("binary");\n');
r.write('ss');
r.write('.');

r.close();