Skip to content

Commit 6fe6dab

Browse files
authored
Fix parseFloat input string length calculation (#3782)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent b2a2022 commit 6fe6dab

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

jerry-core/ecma/base/ecma-helpers-number.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
941941
/* The input string should be at least the length of "Infinity" to be correctly processed as
942942
* the infinity value.
943943
*/
944-
if (string_buff_size >= infinity_length
944+
if ((str_end_p - str_curr_p) >= (int) infinity_length
945945
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
946946
{
947947
/* String matched Infinity. */
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
assert (parseFloat (-0.00001) === -0.00001);

0 commit comments

Comments
 (0)