Fixing memory leak in ecma_op_string_object_get_own_property.

This commit is contained in:
Ruben Ayrapetyan 2014-10-15 14:51:42 +04:00
parent 7dcbeec487
commit 2a8adf7698

View File

@ -150,27 +150,32 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the array obj
int32_t length = ecma_string_get_length (prim_value_str_p); int32_t length = ecma_string_get_length (prim_value_str_p);
JERRY_ASSERT (length >= 0); JERRY_ASSERT (length >= 0);
// 7. ecma_property_t *new_prop_p;
if (uint32_index >= (uint32_t) length) if (uint32_index >= (uint32_t) length)
{ {
return NULL; // 7.
new_prop_p = NULL;
} }
else
{
// 8. // 8.
ecma_char_t c = ecma_string_get_char_at_pos (prim_value_str_p, uint32_index); ecma_char_t c = ecma_string_get_char_at_pos (prim_value_str_p, uint32_index);
// 9. // 9.
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p, new_prop_p = ecma_create_named_data_property (obj_p,
new_prop_name_p, new_prop_name_p,
false, false,
true, true,
false); false);
ecma_deref_ecma_string (new_prop_name_p);
ecma_char_t new_prop_zt_str_p [2] = { c, ECMA_CHAR_NULL }; ecma_char_t new_prop_zt_str_p [2] = { c, ECMA_CHAR_NULL };
ecma_string_t *new_prop_str_value_p = ecma_new_ecma_string (new_prop_zt_str_p); ecma_string_t *new_prop_str_value_p = ecma_new_ecma_string (new_prop_zt_str_p);
ecma_value_t new_prop_str_value = ecma_make_string_value (new_prop_str_value_p); ecma_value_t new_prop_str_value = ecma_make_string_value (new_prop_str_value_p);
new_prop_p->u.named_data_property.value = new_prop_str_value; new_prop_p->u.named_data_property.value = new_prop_str_value;
}
ecma_deref_ecma_string (new_prop_name_p);
return new_prop_p; return new_prop_p;
} /* ecma_op_string_object_get_own_property */ } /* ecma_op_string_object_get_own_property */