From efdf91a0d6bb10d27a1ed80394ead3d59438d141 Mon Sep 17 00:00:00 2001 From: Youngil Choi Date: Mon, 22 Aug 2016 15:41:28 +0900 Subject: [PATCH] Regexp.prototype.exec should not generate return array with [[Put]] Releated issue: #1078 JerryScript-DCO-1.0-Signed-off-by: Youngil Choi duddlf.choi@samsung.com --- .../ecma/operations/ecma-regexp-object.c | 14 ++++++-------- tests/jerry/regression-test-issue-1078.js | 19 +++++++++++++++++++ tests/jerry/regression-test-issue-787.js | 11 +---------- 3 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 tests/jerry/regression-test-issue-1078.js diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 0210940e9..1aeca9962 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -1434,15 +1434,13 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */ capture_value = ecma_make_string_value (capture_str_p); } - ECMA_TRY_CATCH (put_value, - ecma_op_object_put (result_array_obj_p, - index_str_p, - capture_value, - true), - ret_value); - ECMA_FINALIZE (put_value); + ecma_property_t *prop_p; + prop_p = ecma_create_named_data_property (result_array_obj_p, + index_str_p, + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + ecma_set_named_data_property_value (prop_p, capture_value); - ecma_free_value (capture_value); + JERRY_ASSERT (!ecma_is_value_object (capture_value)); ecma_deref_ecma_string (index_str_p); } diff --git a/tests/jerry/regression-test-issue-1078.js b/tests/jerry/regression-test-issue-1078.js new file mode 100644 index 000000000..25ae8b1fd --- /dev/null +++ b/tests/jerry/regression-test-issue-1078.js @@ -0,0 +1,19 @@ +// Copyright 2016 Samsung Electronics Co., Ltd. +// Copyright 2016 University of Szeged. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +Array.prototype.splice(Function.prototype, 1, this); +Object.freeze(Array.prototype); +var res = (new String("Hello")).split(new RegExp()); +assert(res.length == 5); diff --git a/tests/jerry/regression-test-issue-787.js b/tests/jerry/regression-test-issue-787.js index b822cf65d..a5be343d2 100644 --- a/tests/jerry/regression-test-issue-787.js +++ b/tests/jerry/regression-test-issue-787.js @@ -15,13 +15,4 @@ Array.prototype.push(Math.sin); Object.freeze(Array.prototype); - -try -{ - String.prototype.match(String.prototype); - assert (false); -} -catch (e) -{ - assert (e instanceof TypeError); -} +String.prototype.match(String.prototype);