Skip to content

Commit 00f8209

Browse files
committed
Avoid freeing arena allocation in error path
hashmap_node_new() allocates both the node and key via arena_alloc(HASHMAP_ARENA). Calling free(node) when key allocation fails is incorrect because the arena owns lifetime. Remove the invalid free to avoid mixing allocators.
1 parent d2e1d20 commit 00f8209

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

src/globals.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,8 @@ hashmap_node_t *hashmap_node_new(char *key, void *val)
420420
}
421421

422422
node->key = arena_alloc(HASHMAP_ARENA, len + 1);
423-
424423
if (!node->key) {
425424
printf("Failed to allocate hashmap_node_t key with size %d\n", len + 1);
426-
free(node);
427425
return NULL;
428426
}
429427

0 commit comments

Comments
 (0)