Skip to content

Commit fbca37f

Browse files
authored
Fix argument validation for Number.prototype.toPrecision (#3176)
This patch fixes #3173 JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 195b0d3 commit fbca37f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ ecma_builtin_number_prepare_conversion (ecma_number_t *this_num_p, /**< [out] th
632632
}
633633

634634
if (mode == NUMBER_ROUTINE_TO_PRECISION &&
635-
(arg_num < 1 || arg_num >= 22))
635+
(ecma_number_is_nan (arg_num) || arg_num < 1 || arg_num >= 22))
636636
{
637-
return ecma_raise_range_error (ECMA_ERR_MSG ("Precision digits must be between 0 and 21."));
637+
return ecma_raise_range_error (ECMA_ERR_MSG ("Precision digits must be between 1 and 21."));
638638
}
639639

640640
*arg_1_int32_p = ecma_number_to_int32 (arg_num);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var NISLFuzzingFunc = function(d, c) {
16+
var a = d.toPrecision(c);
17+
};
18+
var NISLParameter0 = 59246;
19+
var NISLParameter1 = function(p) {
20+
};
21+
NISLFuzzingFunc(NISLParameter0, NISLParameter1);

0 commit comments

Comments
 (0)