From b16b400d5ba6e7e23e082c76ab8a28b82136d994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Tue, 12 Nov 2019 10:54:26 +0100 Subject: [PATCH] Fix cleanup upon error in String.prototype.replace (#3301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3297 JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu --- .../ecma-builtin-string-prototype.c | 2 +- tests/jerry/fail/regression-test-issue-3297.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/jerry/fail/regression-test-issue-3297.js diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index f37eab89e..77e80738f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -623,7 +623,7 @@ ecma_builtin_string_prototype_object_replace (ecma_value_t this_value, /**< this if (ECMA_IS_VALUE_ERROR (result)) { ecma_stringbuilder_destroy (&replace_ctx.builder); - goto cleanup_search; + goto cleanup_replace; } ecma_string_t *const result_str_p = ecma_op_to_string (result); diff --git a/tests/jerry/fail/regression-test-issue-3297.js b/tests/jerry/fail/regression-test-issue-3297.js new file mode 100644 index 000000000..cf3a84f79 --- /dev/null +++ b/tests/jerry/fail/regression-test-issue-3297.js @@ -0,0 +1,15 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// 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. + +"98765".replace(76, function ( ) { return $ })