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 de59a65e01..0f64a9072f 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 @@ -553,6 +553,11 @@ ecma_builtin_typedarray_prototype_filter (ecma_value_t this_arg, /**< this argum ecma_object_t *func_object_p = ecma_get_object_from_value (cb_func_val); ecma_value_t ret_value = ECMA_VALUE_EMPTY; + if (len == 0) + { + return ecma_op_create_typedarray_with_type_and_length (obj_p, 0); + } + JMEM_DEFINE_LOCAL_ARRAY (pass_value_list_p, len * element_size, lit_utf8_byte_t); lit_utf8_byte_t *pass_value_p = pass_value_list_p; @@ -588,7 +593,6 @@ ecma_builtin_typedarray_prototype_filter (ecma_value_t this_arg, /**< this argum ret_value = ecma_op_create_typedarray_with_type_and_length (obj_p, pass_num); - if (!ECMA_IS_VALUE_ERROR (ret_value)) { obj_p = ecma_get_object_from_value (ret_value); diff --git a/tests/jerry/es2015/regression-test-issue-2435.js b/tests/jerry/es2015/regression-test-issue-2435.js new file mode 100644 index 0000000000..0f70cca611 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-2435.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. + +(new Int8Array(0)).filter(parseInt)