Segfault with insufficient item on stack.
h3rald h3rald@h3rald.com
Tue, 31 Dec 2024 07:14:56 +0000
1 files changed,
6 insertions(+),
4 deletions(-)
jump to
M
src/registry.c
→
src/registry.c
@@ -150,7 +150,7 @@ {
if (strcmp(entry->key, key) == 0) { // Key already exists, update its value - hex_free_item(NULL, entry->value); // Free old value + hex_free_item(ctx, entry->value); // Free old value entry->value = value; return 0; }@@ -210,12 +210,14 @@ {
if (strcmp(entry->key, key) == 0) { // Key found, copy the value to result - result = hex_copy_item(ctx, entry->value); // Copy the value structure - if (result == NULL) + HEX_ALLOC(item); + item = hex_copy_item(ctx, entry->value); // Copy the value structure + if (item == NULL) { hex_error(ctx, "[get symbol] Failed to copy item for key: %s", key); return 0; } + *result = *item; hex_debug_item(ctx, "DONE", result); return 1; // Success }@@ -250,7 +252,7 @@ registry->buckets[bucket_index] = entry->next;
} free(entry->key); - hex_free_item(NULL, entry->value); + hex_free_item(ctx, entry->value); free(entry); registry->size--;