Skip to content

Commit 26f41b0

Browse files
bnoordhuisjuanarbol
authored andcommitted
src: fix c++ exception on bad command line arg
Replace stoull() with strtoull(). The former throws an exception when the input is malformed, the latter doesn't. Fixes: #46223 PR-URL: #46290 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 837ddcb commit 26f41b0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/node_options-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ void OptionsParser<Options>::Parse(
444444
*Lookup<int64_t>(info.field, options) = std::atoll(value.c_str());
445445
break;
446446
case kUInteger:
447-
*Lookup<uint64_t>(info.field, options) = std::stoull(value);
447+
*Lookup<uint64_t>(info.field, options) =
448+
std::strtoull(value.c_str(), nullptr, 10);
448449
break;
449450
case kString:
450451
*Lookup<std::string>(info.field, options) = value;

test/sequential/test-cpu-prof-invalid-options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ const {
5858
}
5959

6060
// --cpu-prof-interval without --cpu-prof
61-
{
61+
for (const arg of [kCpuProfInterval, 'crashme']) {
6262
tmpdir.refresh();
6363
const output = spawnSync(process.execPath, [
6464
'--cpu-prof-interval',
65-
kCpuProfInterval,
65+
arg,
6666
fixtures.path('workload', 'fibonacci.js'),
6767
], {
6868
cwd: tmpdir.path,

0 commit comments

Comments
 (0)