diff --git a/src/node.cc b/src/node.cc index 067993631549d7..c3b0a50e380ca5 100644 --- a/src/node.cc +++ b/src/node.cc @@ -687,10 +687,9 @@ int InitializeNodeWithArgs(std::vector* argv, // Backslashes escape the following character if (c == '\\' && is_in_string) { if (index + 1 == node_options.size()) { - fprintf(stderr, - "%s: invalid escaping for NODE_OPTIONS\n", - argv->at(0).c_str()); - exit(9); + errors->push_back("invalid value for NODE_OPTIONS " + "(invalid escape)\n"); + return 9; } else { c = node_options.at(++index); } @@ -710,6 +709,12 @@ int InitializeNodeWithArgs(std::vector* argv, } } + if (is_in_string) { + errors->push_back("invalid value for NODE_OPTIONS " + "(unterminated string)\n"); + return 9; + } + const int exit_code = ProcessGlobalArgs(&env_argv, nullptr, errors, true); if (exit_code != 0) return exit_code; }