Skip to content

Commit

Permalink
src: fix c++ exception on bad command line arg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
bnoordhuis authored Jan 22, 2023
1 parent de6c0e6 commit 3700d9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ void OptionsParser<Options>::Parse(
*Lookup<int64_t>(info.field, options) = std::atoll(value.c_str());
break;
case kUInteger:
*Lookup<uint64_t>(info.field, options) = std::stoull(value);
*Lookup<uint64_t>(info.field, options) =
std::strtoull(value.c_str(), nullptr, 10);
break;
case kString:
*Lookup<std::string>(info.field, options) = value;
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-cpu-prof-invalid-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const {
}

// --cpu-prof-interval without --cpu-prof
{
for (const arg of [kCpuProfInterval, 'crashme']) {
tmpdir.refresh();
const output = spawnSync(process.execPath, [
'--cpu-prof-interval',
kCpuProfInterval,
arg,
fixtures.path('workload', 'fibonacci.js'),
], {
cwd: tmpdir.path,
Expand Down

0 comments on commit 3700d9e

Please sign in to comment.