| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,18 +256,20 @@ class ProcessWrap : public HandleWrap { | |||
| 256 | 256 | int argc = js_argv->Length(); | |
| 257 | 257 | CHECK_LT(argc, INT_MAX); // Check for overflow. | |
| 258 | 258 | args_vals.reserve(argc); | |
| 259 | - options_args.resize(argc + 1); | ||
| 260 | 259 | for (int i = 0; i < argc; i++) { | |
| 261 | 260 | Local<Value> val; | |
| 262 | 261 | if (!js_argv->Get(context, i).ToLocal(&val)) { | |
| 263 | 262 | return; | |
| 264 | 263 | } | |
| 265 | 264 | node::Utf8Value arg(env->isolate(), val); | |
| 266 | 265 | 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()); | ||
| 268 | 270 | CHECK_NOT_NULL(options_args[i]); | |
| 269 | 271 | } | |
| 270 | - options_args[argc] = nullptr; | ||
| 272 | + options_args.back() = nullptr; | ||
| 271 | 273 | options.args = options_args.data(); | |
| 272 | 274 | } | |
| 273 | 275 | ||
@@ -294,18 +296,20 @@ class ProcessWrap : public HandleWrap { | |||
| 294 | 296 | int envc = env_opt->Length(); | |
| 295 | 297 | CHECK_LT(envc, INT_MAX); // Check for overflow. | |
| 296 | 298 | env_vals.reserve(envc); | |
| 297 | - options_env.resize(envc + 1); | ||
| 298 | 299 | for (int i = 0; i < envc; i++) { | |
| 299 | 300 | Local<Value> val; | |
| 300 | 301 | if (!env_opt->Get(context, i).ToLocal(&val)) { | |
| 301 | 302 | return; | |
| 302 | 303 | } | |
| 303 | 304 | node::Utf8Value pair(env->isolate(), val); | |
| 304 | 305 | 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()); | ||
| 306 | 310 | CHECK_NOT_NULL(options_env[i]); | |
| 307 | 311 | } | |
| 308 | - options_env[envc] = nullptr; | ||
| 312 | + options_env.back() = nullptr; | ||
| 309 | 313 | options.env = options_env.data(); | |
| 310 | 314 | } | |
| 311 | 315 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments