From ee267e8aa9550b1e06cd61de08d3c095b50c0ca0 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Tue, 15 Jan 2019 09:01:33 +0100 Subject: [PATCH] Add missing ecma_deref_ecma_string in ecma_builtin_typedarray_prototype_join (#2701) This patch fixes #2698. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- .../ecma-builtin-typedarray-prototype.c | 1 + .../es2015/regression-test-issue-2698.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/jerry/es2015/regression-test-issue-2698.js diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c index 316e7cc47..7cd12f3a0 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c @@ -1027,6 +1027,7 @@ ecma_builtin_typedarray_prototype_join (ecma_value_t this_arg, /**< this argumen ecma_value_t next_string_value = ecma_op_typedarray_get_to_string_at_index (obj_p, k); if (ECMA_IS_VALUE_ERROR (next_string_value)) { + ecma_deref_ecma_string (return_string_p); ecma_free_value (first_value); ecma_free_value (separator_value); ecma_free_value (length_value); diff --git a/tests/jerry/es2015/regression-test-issue-2698.js b/tests/jerry/es2015/regression-test-issue-2698.js new file mode 100644 index 000000000..44bd3ec11 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-2698.js @@ -0,0 +1,20 @@ +// 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. + +try { + Uint8Array.prototype.join.call([ "2015-01-01T00:", { toString : '2,1,3,4,0' } ], [ ]) ; + assert (false); +} catch (e) { + assert (e instanceof TypeError); +}