Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8fac4c5

Browse filesBrowse files
deokjinkimjuanarbol
authored andcommitted
perf_hooks: fix checking range of options.figures in createHistogram
For `options.figures`, number between 1 and 5 is allowed. So need to use `validateInteger` to limit max as 5. Refs: https://github.com/nodejs/node/blob/main/doc/api/perf_hooks.md#perf_hookscreatehistogramoptions PR-URL: #45999 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7e1462d commit 8fac4c5
Copy full SHA for 8fac4c5

File tree

Expand file treeCollapse file tree

2 files changed

+8
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/histogram.js‎

Copy file name to clipboardExpand all lines: lib/internal/histogram.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const {
3636
validateInteger,
3737
validateNumber,
3838
validateObject,
39-
validateUint32,
4039
} = require('internal/validators');
4140

4241
const kDestroy = Symbol('kDestroy');
@@ -368,7 +367,7 @@ function createHistogram(options = kEmptyObject) {
368367
} else if (highest < 2n * lowest) {
369368
throw new ERR_INVALID_ARG_VALUE.RangeError('options.highest', highest);
370369
}
371-
validateUint32(figures, 'options.figures', 1, 5);
370+
validateInteger(figures, 'options.figures', 1, 5);
372371
return internalRecordableHistogram(new _Histogram(lowest, highest, figures));
373372
}
374373

Collapse file

‎test/parallel/test-perf-hooks-histogram.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-histogram.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ const { inspect } = require('util');
135135
});
136136
});
137137

138+
// Number greater than 5 is not allowed
139+
for (const i of [6, 10]) {
140+
throws(() => createHistogram({ figures: i }), {
141+
code: 'ERR_OUT_OF_RANGE',
142+
});
143+
}
144+
138145
createHistogram({ lowest: 1, highest: 11, figures: 1 });
139146
}
140147

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.