Skip to content

Commit 9d76c13

Browse files
committed
Fix adding entries to the internal buffer of a Map object
When appending the key/value pair separately, garbage collection could be triggered before the value is added, which could cause problems during marking. This patch changes insertion to add both values at the same time, which prevents partial entries from being present in the internal buffer. Fixes #3804. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
1 parent 8f76a1f commit 9d76c13

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

jerry-core/ecma/operations/ecma-container-object.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ ecma_op_internal_buffer_append (ecma_collection_t *container_p, /**< internal co
6464
{
6565
JERRY_ASSERT (container_p != NULL);
6666

67-
ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (key_arg));
68-
6967
if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_MAP_UL)
7068
{
71-
ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (value_arg));
69+
ecma_value_t values[] = { ecma_copy_value_if_not_object (key_arg), ecma_copy_value_if_not_object (value_arg) };
70+
ecma_collection_append (container_p, values, 2);
71+
}
72+
else
73+
{
74+
ecma_collection_push_back (container_p, ecma_copy_value_if_not_object (key_arg));
7275
}
7376

7477
ECMA_CONTAINER_SET_SIZE (container_p, ECMA_CONTAINER_GET_SIZE (container_p) + 1);

0 commit comments

Comments
 (0)