jerryscript/jerry-core/ecma/operations/ecma-proxy-object.h
Péter Gál 5e483633f3
Fix prototype chain traversing (#4458)
After the introduction of the Proxy builtin object there was
a possibility to traverse the prototype chain with an invalid object.
The prototype was freed before it's data/properties were queried resulting
in accessing invalid information.

By forcing the allocator to always do a gc (`--mem-stres-test=on` build option)
it was possible to trigger the issue without complicated tests.

New internal method:
* `ecma_op_object_get_prototype_of` which always returns the prototype
  of an object and the return value must be freed (if it is valid).

Updated prototype chain traversing in:
* `jerry_object_get_property_names`
* `ecma_builtin_object_prototype_lookup_getter_setter`
* `ecma_op_function_has_instance`
* `ecma_op_function_get_super_constructor`
* `ecma_op_object_is_prototype_of`
* `ecma_op_object_enumerate`

Removed method `ecma_proxy_object_prototype_to_cp`

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-15 20:54:09 +01:00

117 lines
3.5 KiB
C

/* 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.
*/
#ifndef ECMA_PROXY_OBJECT_H
#define ECMA_PROXY_OBJECT_H
#include "ecma-globals.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmaproxyobject ECMA Proxy object related routines
* @{
*/
#if ENABLED (JERRY_BUILTIN_PROXY)
ecma_object_t *
ecma_proxy_create (ecma_value_t target,
ecma_value_t handler);
ecma_object_t *
ecma_proxy_create_revocable (ecma_value_t target,
ecma_value_t handler);
ecma_value_t
ecma_proxy_revoke_cb (const ecma_value_t function_obj,
const ecma_value_t this_val,
const ecma_value_t args_p[],
const uint32_t args_count);
ecma_value_t
ecma_proxy_object_find (ecma_object_t *obj_p,
ecma_string_t *prop_name_p);
/* Interal operations */
ecma_value_t
ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p);
ecma_value_t
ecma_proxy_object_set_prototype_of (ecma_object_t *obj_p,
ecma_value_t proto);
ecma_value_t
ecma_proxy_object_is_extensible (ecma_object_t *obj_p);
ecma_value_t
ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p);
ecma_value_t
ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p,
ecma_string_t *prop_name_p,
ecma_property_descriptor_t *prop_desc_p);
ecma_value_t
ecma_proxy_object_define_own_property (ecma_object_t *obj_p,
ecma_string_t *prop_name_p,
const ecma_property_descriptor_t *prop_desc_p);
ecma_value_t
ecma_proxy_object_has (ecma_object_t *obj_p,
ecma_string_t *prop_name_p);
ecma_value_t
ecma_proxy_object_get (ecma_object_t *obj_p,
ecma_string_t *prop_name_p,
ecma_value_t receiver);
ecma_value_t
ecma_proxy_object_set (ecma_object_t *obj_p,
ecma_string_t *prop_name_p,
ecma_value_t name,
ecma_value_t receiver,
bool is_strict);
ecma_value_t
ecma_proxy_object_delete_property (ecma_object_t *obj_p,
ecma_string_t *prop_name_p,
bool is_strict);
ecma_collection_t *
ecma_proxy_object_own_property_keys (ecma_object_t *obj_p);
ecma_value_t
ecma_proxy_object_call (ecma_object_t *obj_p,
ecma_value_t this_argument,
const ecma_value_t *args_p,
uint32_t argc);
ecma_value_t
ecma_proxy_object_construct (ecma_object_t *obj_p,
ecma_object_t *new_target_p,
const ecma_value_t *args_p,
uint32_t argc);
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
/**
* @}
* @}
*/
#endif /* !ECMA_PROXY_OBJECT_H */