diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-04-15 22:19:59 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-04-17 23:36:37 +0200 |
commit | 002dacb7f7a909c42f0ce69bee5b58e9158b5630 (patch) | |
tree | d64c266ed40b5330f85209162961788142074475 /src/node_worker.cc | |
parent | 652877e3a9eee3f863314382f64f8ac1e5b27186 (diff) | |
download | android-node-v8-002dacb7f7a909c42f0ce69bee5b58e9158b5630.tar.gz android-node-v8-002dacb7f7a909c42f0ce69bee5b58e9158b5630.tar.bz2 android-node-v8-002dacb7f7a909c42f0ce69bee5b58e9158b5630.zip |
worker: handle exception when creating execArgv errors
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: https://github.com/nodejs/node/pull/27162
PR-URL: https://github.com/nodejs/node/pull/27245
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r-- | src/node_worker.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc index bdf324fa04..b9143eca7a 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -459,13 +459,17 @@ 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()); + // Ignore the return value of Set() because exceptions bubble up to JS + // when we return anyway. + USE(args.This()->Set(env->context(), key, error)); return; } } |