@@ -186,8 +186,6 @@ class ProcessWrap : public HandleWrap {
186186 Local<Context> context = env->context ();
187187 ProcessWrap* wrap;
188188 ASSIGN_OR_RETURN_UNWRAP (&wrap, args.This ());
189- THROW_IF_INSUFFICIENT_PERMISSIONS (
190- env, permission::PermissionScope::kChildProcess , " " );
191189 int err = 0 ;
192190
193191 if (!args[0 ]->IsObject ()) {
@@ -201,6 +199,20 @@ class ProcessWrap : public HandleWrap {
201199
202200 options.exit_cb = OnExit;
203201
202+ // TODO(bnoordhuis) is this possible to do without mallocing ?
203+
204+ // options.file
205+ Local<Value> file_v;
206+ if (!js_options->Get (context, env->file_string ()).ToLocal (&file_v)) {
207+ return ;
208+ }
209+ CHECK (file_v->IsString ());
210+ node::Utf8Value file (env->isolate (), file_v);
211+ options.file = *file;
212+
213+ THROW_IF_INSUFFICIENT_PERMISSIONS (
214+ env, permission::PermissionScope::kChildProcess , file.ToStringView ());
215+
204216 // options.uid
205217 Local<Value> uid_v;
206218 if (!js_options->Get (context, env->uid_string ()).ToLocal (&uid_v)) {
@@ -225,17 +237,6 @@ class ProcessWrap : public HandleWrap {
225237 options.gid = static_cast <uv_gid_t >(gid);
226238 }
227239
228- // TODO(bnoordhuis) is this possible to do without mallocing ?
229-
230- // options.file
231- Local<Value> file_v;
232- if (!js_options->Get (context, env->file_string ()).ToLocal (&file_v)) {
233- return ;
234- }
235- CHECK (file_v->IsString ());
236- node::Utf8Value file (env->isolate (), file_v);
237- options.file = *file;
238-
239240 // Undocumented feature of Win32 CreateProcess API allows spawning
240241 // batch files directly but is potentially insecure because arguments
241242 // are not escaped (and sometimes cannot be unambiguously escaped),
0 commit comments