From 03202995a0e1c4b090c938a631bc200acc6f2477 Mon Sep 17 00:00:00 2001 From: Szilagyi Adam Date: Fri, 21 Jun 2019 19:02:06 +0200 Subject: [PATCH] Add missing release to ecma_op_container_foreach (#2912) The result of the callback function was not freed Fixes #2910 Co-authored-by: Tibor Dusnoki tdusnoki@inf.u-szeged.hu JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu --- .../ecma/operations/ecma-container-object.c | 2 ++ .../jerry/es2015/regression-test-issue-2910.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/jerry/es2015/regression-test-issue-2910.js diff --git a/jerry-core/ecma/operations/ecma-container-object.c b/jerry-core/ecma/operations/ecma-container-object.c index 003d6fb1c..b22bc6729 100644 --- a/jerry-core/ecma/operations/ecma-container-object.c +++ b/jerry-core/ecma/operations/ecma-container-object.c @@ -548,6 +548,8 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */ break; } + ecma_free_value (call_value); + ecma_value_p = ecma_collection_iterator_next (ecma_value_p); } diff --git a/tests/jerry/es2015/regression-test-issue-2910.js b/tests/jerry/es2015/regression-test-issue-2910.js new file mode 100644 index 000000000..5ad8dbd22 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-2910.js @@ -0,0 +1,18 @@ +/* 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. + */ + +var map = new Map ; +for (var i = 0; i < 15 ; i ++ ) { map.set() } +map.forEach ( Number )