Skip to content

Commit a4ee88c

Browse files
author
Daniel Balla
committed
Fix for null pointer dereference in jmem_heap_free_block
Fixes #2435. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla [email protected]
1 parent 8482fef commit a4ee88c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ ecma_builtin_typedarray_prototype_filter (ecma_value_t this_arg, /**< this argum
553553
ecma_object_t *func_object_p = ecma_get_object_from_value (cb_func_val);
554554
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
555555

556+
if (len == 0)
557+
{
558+
return ecma_op_create_typedarray_with_type_and_length (obj_p, 0);
559+
}
560+
556561
JMEM_DEFINE_LOCAL_ARRAY (pass_value_list_p, len * element_size, lit_utf8_byte_t);
557562

558563
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
588593

589594
ret_value = ecma_op_create_typedarray_with_type_and_length (obj_p, pass_num);
590595

591-
592596
if (!ECMA_IS_VALUE_ERROR (ret_value))
593597
{
594598
obj_p = ecma_get_object_from_value (ret_value);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
(new Int8Array(0)).filter(parseInt)

0 commit comments

Comments
 (0)