Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
src: fill options_args, options_env after vectors are finalized
  • Loading branch information
iknoom committed Sep 22, 2025
commit 985fed46d6af2b880e0d3785127ce861094f42a5
16 changes: 10 additions & 6 deletions src/process_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,20 @@ class ProcessWrap : public HandleWrap {
int argc = js_argv->Length();
CHECK_LT(argc, INT_MAX); // Check for overflow.
args_vals.reserve(argc);
options_args.resize(argc + 1);
for (int i = 0; i < argc; i++) {
Local<Value> val;
if (!js_argv->Get(context, i).ToLocal(&val)) {
return;
}
node::Utf8Value arg(env->isolate(), val);
args_vals.emplace_back(arg.ToString());
options_args[i] = const_cast<char*>(args_vals.back().c_str());
}
options_args.resize(args_vals.size() + 1);
for (size_t i = 0; i < args_vals.size(); i++) {
options_args[i] = const_cast<char*>(args_vals[i].c_str());
CHECK_NOT_NULL(options_args[i]);
Comment thread
addaleax marked this conversation as resolved.
Resolved
}
options_args[argc] = nullptr;
options_args.back() = nullptr;
options.args = options_args.data();
}

Expand All @@ -294,18 +296,20 @@ class ProcessWrap : public HandleWrap {
int envc = env_opt->Length();
CHECK_LT(envc, INT_MAX); // Check for overflow.
env_vals.reserve(envc);
options_env.resize(envc + 1);
for (int i = 0; i < envc; i++) {
Local<Value> val;
if (!env_opt->Get(context, i).ToLocal(&val)) {
return;
}
node::Utf8Value pair(env->isolate(), val);
env_vals.emplace_back(pair.ToString());
options_env[i] = const_cast<char*>(env_vals.back().c_str());
}
options_env.resize(env_vals.size() + 1);
for (size_t i = 0; i < env_vals.size(); i++) {
options_env[i] = const_cast<char*>(env_vals[i].c_str());
CHECK_NOT_NULL(options_env[i]);
Comment thread
addaleax marked this conversation as resolved.
Resolved
}
options_env[envc] = nullptr;
options_env.back() = nullptr;
options.env = options_env.data();
}

Expand Down
Loading