From 748e1be0414bbb8c4d7abfb54800c2183221f1f1 Mon Sep 17 00:00:00 2001 From: kisbg Date: Mon, 1 Feb 2021 16:49:12 +0100 Subject: [PATCH] Minor fix in create ArrayBuffer object (#4556) JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu --- .../ecma/operations/ecma-arraybuffer-object.c | 18 ++++++++++-------- tests/test262-esnext-excludelist.xml | 1 - 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index 8f45ffe4d..d79589da2 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -109,6 +109,14 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); + ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), + ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE); + + if (proto_p == NULL) + { + return ECMA_VALUE_ERROR; + } + ecma_number_t length_num = 0; if (arguments_list_len > 0) @@ -124,6 +132,7 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li if (ECMA_IS_VALUE_ERROR (to_number_value)) { + ecma_deref_object (proto_p); return to_number_value; } } @@ -137,20 +146,13 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li if (length_num <= -1.0 || length_num > (ecma_number_t) maximum_size_in_byte + 0.5) { + ecma_deref_object (proto_p); return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid ArrayBuffer length")); } } uint32_t length_uint32 = ecma_number_to_uint32 (length_num); - ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), - ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE); - - if (proto_p == NULL) - { - return ECMA_VALUE_ERROR; - } - ecma_object_t *array_buffer = ecma_arraybuffer_new_object (length_uint32); ECMA_SET_NON_NULL_POINTER (array_buffer->u2.prototype_cp, proto_p); ecma_deref_object (proto_p); diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index f38fbedfe..ec55531c5 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -2,7 +2,6 @@ -