summaryrefslogtreecommitdiff
path: root/src/process_wrap.cc
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-10-18 15:04:41 -0400
committercjihrig <cjihrig@gmail.com>2016-12-25 12:48:55 -0500
commit45c9ca7fd430022a9c0567e1b9f535b3e3f956fd (patch)
tree4a9d83f219edc6117286bc143daf36859188568a /src/process_wrap.cc
parentfc7b0dda85c006e5830a0e34645d769e20b894d2 (diff)
downloadandroid-node-v8-45c9ca7fd430022a9c0567e1b9f535b3e3f956fd.tar.gz
android-node-v8-45c9ca7fd430022a9c0567e1b9f535b3e3f956fd.tar.bz2
android-node-v8-45c9ca7fd430022a9c0567e1b9f535b3e3f956fd.zip
src: remove redundant spawn/spawnSync type checks
This commit removes C++ checks from spawn() and spawnSync() that are duplicates of the JavaScript type checking. Fixes: https://github.com/nodejs/node/issues/8096 Fixes: https://github.com/nodejs/node/issues/8539 Refs: https://github.com/nodejs/node/issues/9722 PR-URL: https://github.com/nodejs/node/pull/8312 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/process_wrap.cc')
-rw-r--r--src/process_wrap.cc20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/process_wrap.cc b/src/process_wrap.cc
index 3dcde0962a..8c8e4704be 100644
--- a/src/process_wrap.cc
+++ b/src/process_wrap.cc
@@ -121,35 +121,29 @@ class ProcessWrap : public HandleWrap {
// options.uid
Local<Value> uid_v = js_options->Get(env->uid_string());
- if (uid_v->IsInt32()) {
+ if (!uid_v->IsUndefined() && !uid_v->IsNull()) {
+ CHECK(uid_v->IsInt32());
const int32_t uid = uid_v->Int32Value(env->context()).FromJust();
options.flags |= UV_PROCESS_SETUID;
options.uid = static_cast<uv_uid_t>(uid);
- } else if (!uid_v->IsUndefined() && !uid_v->IsNull()) {
- return env->ThrowTypeError("options.uid should be a number");
}
// options.gid
Local<Value> gid_v = js_options->Get(env->gid_string());
- if (gid_v->IsInt32()) {
+ if (!gid_v->IsUndefined() && !gid_v->IsNull()) {
+ CHECK(gid_v->IsInt32());
const int32_t gid = gid_v->Int32Value(env->context()).FromJust();
options.flags |= UV_PROCESS_SETGID;
options.gid = static_cast<uv_gid_t>(gid);
- } else if (!gid_v->IsUndefined() && !gid_v->IsNull()) {
- return env->ThrowTypeError("options.gid should be a number");
}
// TODO(bnoordhuis) is this possible to do without mallocing ?
// options.file
Local<Value> file_v = js_options->Get(env->file_string());
- node::Utf8Value file(env->isolate(),
- file_v->IsString() ? file_v : Local<Value>());
- if (file.length() > 0) {
- options.file = *file;
- } else {
- return env->ThrowTypeError("Bad argument");
- }
+ CHECK(file_v->IsString());
+ node::Utf8Value file(env->isolate(), file_v);
+ options.file = *file;
// options.args
Local<Value> argv_v = js_options->Get(env->args_string());