Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-json.c (C)

Code before:
          ecma_deref_object (object_p);
          return new_element;
        }

        if (ecma_is_value_undefined (new_element))
        {
          ecma_value_t delete_val = ecma_op_object_delete_by_uint32_index (object_p,
                                                                           i,
                                                                           false);
          JERRY_ASSERT (ecma_is_value_boolean (delete_val));
        }
        else
        {
          ecma_builtin_json_define_value_property (object_p,
                                                   prop_index,
                                                   new_element);
          ecma_free_value (new_element);
        }

        ecma_deref_ecma_string (prop_index);
      }
    }
    /* 3.d */
    else
    {
      ecma_collection_t *props_p = ecma_op_object_get_property_names (object_p, ECMA_LIST_ENUMERABLE);

      ecma_value_t *buffer_p = props_p->buffer_p;

      /* 3.d.iii */
      for (uint32_t i = 0; i < props_p->item_count; i++)
      {
        ecma_string_t *property_name_p = ecma_get_string_from_value (buffer_p[i]);

        /* 3.d.iii.1 */
        ecma_value_t result = ecma_builtin_json_internalize_property (reviver_p, object_p, property_name_p);

        /* 3.d.iii.2 */
        if (ECMA_IS_VALUE_ERROR (result))
        {
          ecma_collection_free (props_p);
          ecma_deref_object (object_p);

          return result;
        }

        /* 3.d.iii.3 */
        if (ecma_is_value_undefined (result))
        {
          ecma_value_t delete_val = ecma_op_general_object_delete (object_p,
                                                                  property_name_p,

Review comment (suggestion):
This operation might throw error, if `object_p` is a proxy object. Please add testcase for it as well.

Code after:
          ecma_deref_object (object_p);
          return new_element;
        }

        if (ecma_is_value_undefined (new_element))
        {
          ecma_value_t delete_val = ecma_op_object_delete_by_uint32_index (object_p,
                                                                           i,
                                                                           false);
          JERRY_ASSERT (ecma_is_value_boolean (delete_val));
        }
        else
        {
          ecma_builtin_json_define_value_property (object_p,
                                                   prop_index,
                                                   new_element);
          ecma_free_value (new_element);
        }

        ecma_deref_ecma_string (prop_index);
      }
    }
    /* 3.d */
    else
    {
      ecma_collection_t *props_p = ecma_op_object_get_property_names (object_p, ECMA_LIST_ENUMERABLE);

      JERRY_ASSERT (props_p != NULL);

      ecma_value_t *buffer_p = props_p->buffer_p;

      /* 3.d.iii */
      for (uint32_t i = 0; i < props_p->item_count; i++)
      {
        ecma_string_t *property_name_p = ecma_get_string_from_value (buffer_p[i]);

        /* 3.d.iii.1 */
        ecma_value_t result = ecma_builtin_json_internalize_property (reviver_p, object_p, property_name_p);

        /* 3.d.iii.2 */
        if (ECMA_IS_VALUE_ERROR (result))
        {
          ecma_collection_free (props_p);
          ecma_deref_object (object_p);

          return result;
        }

        /* 3.d.iii.3 */
        if (ecma_is_value_undefined (result))
        {