[native pointer] Check if freecb is NULL before calling it (#1789)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
@@ -132,6 +132,7 @@ handler_construct_freecb (void *native_p)
|
||||
|
||||
JERRY_DEFINE_NATIVE_HANDLE_INFO (bind1, handler_construct_freecb);
|
||||
JERRY_DEFINE_NATIVE_HANDLE_INFO (bind2, handler_construct_freecb);
|
||||
JERRY_DEFINE_NATIVE_HANDLE_INFO (bind3, NULL);
|
||||
|
||||
static jerry_value_t
|
||||
handler_construct (const jerry_value_t func_obj_val, /**< function object */
|
||||
@@ -768,6 +769,14 @@ main (void)
|
||||
|
||||
jerry_release_value (res);
|
||||
|
||||
/* Test: It is ok to set native pointer's free callback as NULL. */
|
||||
jerry_value_t obj_freecb = jerry_create_object ();
|
||||
jerry_set_object_native_pointer (obj_freecb,
|
||||
(void *) 0x1234,
|
||||
&JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind3));
|
||||
|
||||
jerry_release_value (obj_freecb);
|
||||
|
||||
/* Test: Throwing exception from native handler. */
|
||||
throw_test_handler_val = jerry_create_external_function (handler_throw_test);
|
||||
TEST_ASSERT (jerry_value_is_function (throw_test_handler_val));
|
||||
|
||||
Reference in New Issue
Block a user