Skip to content

Commit

Permalink
worker: handle exception when creating execArgv errors
Browse files Browse the repository at this point in the history
Handle possible JS exceptions that can occur by returning to JS land
immediately.

The motivation for this change is that `USE(….FromJust());` is an
anti-pattern, and `.FromJust()` with an unused return value is
superseded by `.Check()`. However, in this case, checking that the
operation succeeded is not necessary.

Refs: nodejs#27162
  • Loading branch information
addaleax committed Apr 15, 2019
1 parent 7938238 commit 3ff001f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,15 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
// The first argument is program name.
invalid_args.erase(invalid_args.begin());
if (errors.size() > 0 || invalid_args.size() > 0) {
v8::Local<v8::Value> error =
ToV8Value(env->context(),
errors.size() > 0 ? errors : invalid_args)
.ToLocalChecked();
v8::Local<v8::Value> error;
if (!ToV8Value(env->context(),
errors.size() > 0 ? errors : invalid_args)
.ToLocal(&error)) {
return;
}
Local<String> key =
FIXED_ONE_BYTE_STRING(env->isolate(), "invalidExecArgv");
USE(args.This()->Set(env->context(), key, error).FromJust());
USE(args.This()->Set(env->context(), key, error));
return;
}
}
Expand Down

0 comments on commit 3ff001f

Please sign in to comment.