Skip to content

Commit 726ef40

Browse files
Lxxyxtargos
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 77c7d97 commit 726ef40

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎lib/internal/histogram.js‎

Lines changed: 2 additions & 2 deletions
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(typeofpercentile!=='number')
6262
thrownewERR_INVALID_ARG_TYPE('percentile','number',percentile);
6363

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

6767
returnthis[kHandle]?.percentile(percentile);

‎test/sequential/test-performance-eventloopdelay.js‎

Lines changed: 1 addition & 1 deletion
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)