Skip to content

Commit 0971d4d

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 0971d4d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 5 additions & 0 deletions
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 ret_value;
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;

jerry-core/jmem/jmem.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,11 @@ void jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t s
195195
* if it was allocated (i.e. if the array's size was non-zero).
196196
*/
197197
#define JMEM_FINALIZE_LOCAL_ARRAY(var_name) \
198-
if (var_name != NULL) \
198+
if (JERRY_LIKELY (var_name ## ___size != 0)) \
199199
{ \
200-
JERRY_ASSERT (var_name ## ___size != 0); \
201-
\
200+
JERRY_ASSERT (var_name != NULL); \
202201
jmem_heap_free_block (var_name, var_name ## ___size); \
203202
} \
204-
else \
205-
{ \
206-
JERRY_ASSERT (var_name ## ___size == 0); \
207-
} \
208203
}
209204

210205
/**

0 commit comments

Comments
 (0)