Fix property descriptor queries (#3840)

When the getOwnPropertyDescriptor method was invoked the input property
descriptor was not cleared in every case. This could lead to problems when
the property descriptor is not set/modified by the getOwnPropertyDescriptor
call, resulting in a failure at a later state.

Related to this the Proxy getOwnPropertyDescriptor method incorrectly returned
"undefined" value in a single case.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
Péter Gál
2020-06-05 12:28:34 +02:00
committed by GitHub
parent 252cfb0876
commit 0d4116933f
3 changed files with 38 additions and 3 deletions
+4 -2
View File
@@ -1858,6 +1858,8 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
* [Enumerable], [Configurable]
* }.
*
* The output property descriptor will always be initialized to an empty descriptor.
*
* @return true - if property found
* false - otherwise
*/
@@ -1866,6 +1868,8 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
ecma_string_t *property_name_p, /**< property name */
ecma_property_descriptor_t *prop_desc_p) /**< property descriptor */
{
*prop_desc_p = ecma_make_empty_property_descriptor ();
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
if (ECMA_OBJECT_IS_PROXY (object_p))
{
@@ -1885,8 +1889,6 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
return ECMA_VALUE_FALSE;
}
*prop_desc_p = ecma_make_empty_property_descriptor ();
uint32_t flags = ecma_is_property_enumerable (property) ? ECMA_PROP_IS_ENUMERABLE : ECMA_PROP_NO_OPTS;
flags |= ecma_is_property_configurable (property) ? ECMA_PROP_IS_CONFIGURABLE: ECMA_PROP_NO_OPTS;
@@ -735,7 +735,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
/* .a */
if (ecma_is_value_false (target_status))
{
return ECMA_VALUE_UNDEFINED;
return ECMA_VALUE_FALSE;
}
/* .b */
if (!(target_desc.flags & ECMA_PROP_IS_CONFIGURABLE))