Skip to content

Commit

Permalink
Fix cleanup upon error in String.prototype.replace (#3301)
Browse files Browse the repository at this point in the history
Fixes #3297

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
  • Loading branch information
dbatyai authored and zherczeg committed Nov 12, 2019
1 parent 452c781 commit b16b400
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions tests/jerry/fail/regression-test-issue-3297.js
Original file line number Diff line number Diff line change
@@ -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 $ })

0 comments on commit b16b400

Please sign in to comment.