Skip to content

Commit 3f75a60

Browse files
Lxxyxruyadorno
authored andcommitted
perf_hooks: throw ERR_INVALID_ARG_VALUE if histogram.percentile param is NaN
Fixes: #36936 PR-URL: #36937 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 9951dae commit 3f75a60

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/internal/histogram.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {
55
} = require('internal/util');
66

77
const { format } = require('util');
8-
const { SafeMap, Symbol } = primordials;
8+
const { NumberIsNaN, SafeMap, Symbol } = primordials;
99

1010
const {
1111
ERR_INVALID_ARG_TYPE,
@@ -61,7 +61,7 @@ class Histogram {
6161
if (typeof percentile !== 'number')
6262
throw new ERR_INVALID_ARG_TYPE('percentile', 'number', percentile);
6363

64-
if (percentile <= 0 || percentile > 100)
64+
if (NumberIsNaN(percentile) || percentile <= 0 || percentile > 100)
6565
throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile);
6666

6767
return this[kHandle]?.percentile(percentile);

test/sequential/test-performance-eventloopdelay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const { sleep } = require('internal/util');
8686
}
8787
);
8888
});
89-
[-1, 0, 101].forEach((i) => {
89+
[-1, 0, 101, NaN].forEach((i) => {
9090
assert.throws(
9191
() => histogram.percentile(i),
9292
{

0 commit comments

Comments
 (0)