Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54b439f

Browse filesBrowse files
iknoomaduh95
authored andcommitted
src: fill options_args, options_env after vectors are finalized
PR-URL: #59945 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent c7c597e commit 54b439f
Copy full SHA for 54b439f

File tree

Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed
Open diff view settings
Collapse file

‎src/process_wrap.cc‎

Copy file name to clipboardExpand all lines: src/process_wrap.cc
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,20 @@ class ProcessWrap : public HandleWrap {
256256
int argc = js_argv->Length();
257257
CHECK_LT(argc, INT_MAX); // Check for overflow.
258258
args_vals.reserve(argc);
259-
options_args.resize(argc + 1);
260259
for (int i = 0; i < argc; i++) {
261260
Local<Value> val;
262261
if (!js_argv->Get(context, i).ToLocal(&val)) {
263262
return;
264263
}
265264
node::Utf8Value arg(env->isolate(), val);
266265
args_vals.emplace_back(arg.ToString());
267-
options_args[i] = const_cast<char*>(args_vals.back().c_str());
266+
}
267+
options_args.resize(args_vals.size() + 1);
268+
for (size_t i = 0; i < args_vals.size(); i++) {
269+
options_args[i] = const_cast<char*>(args_vals[i].c_str());
268270
CHECK_NOT_NULL(options_args[i]);
269271
}
270-
options_args[argc] = nullptr;
272+
options_args.back() = nullptr;
271273
options.args = options_args.data();
272274
}
273275

@@ -294,18 +296,20 @@ class ProcessWrap : public HandleWrap {
294296
int envc = env_opt->Length();
295297
CHECK_LT(envc, INT_MAX); // Check for overflow.
296298
env_vals.reserve(envc);
297-
options_env.resize(envc + 1);
298299
for (int i = 0; i < envc; i++) {
299300
Local<Value> val;
300301
if (!env_opt->Get(context, i).ToLocal(&val)) {
301302
return;
302303
}
303304
node::Utf8Value pair(env->isolate(), val);
304305
env_vals.emplace_back(pair.ToString());
305-
options_env[i] = const_cast<char*>(env_vals.back().c_str());
306+
}
307+
options_env.resize(env_vals.size() + 1);
308+
for (size_t i = 0; i < env_vals.size(); i++) {
309+
options_env[i] = const_cast<char*>(env_vals[i].c_str());
306310
CHECK_NOT_NULL(options_env[i]);
307311
}
308-
options_env[envc] = nullptr;
312+
options_env.back() = nullptr;
309313
options.env = options_env.data();
310314
}
311315

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.