Skip to content

Commit db9b74a

Browse files
galpeteregavrin
authored andcommitted
Fix buffer size calculation in parseInt.
Fixes issue #279. JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent d2457b1 commit db9b74a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /*
110110
ECMA_TRY_CATCH (string_var, ecma_op_to_string (string), ret_value);
111111

112112
ecma_string_t *number_str_p = ecma_get_string_from_value (string_var);
113-
ecma_length_t str_size = ecma_string_get_length (number_str_p);
113+
lit_utf8_size_t str_size = ecma_string_get_size (number_str_p);
114114

115-
MEM_DEFINE_LOCAL_ARRAY (utf8_string_buff, str_size + 1, lit_utf8_byte_t);
115+
MEM_DEFINE_LOCAL_ARRAY (utf8_string_buff, str_size, lit_utf8_byte_t);
116116

117117
ssize_t bytes_copied = ecma_string_to_utf8_string (number_str_p,
118118
utf8_string_buff,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
assert (isNaN (parseInt (RegExp ("\u2029"))));

0 commit comments

Comments
 (0)