all repos — hex @ ad7bd4bfe43a6167901548d506eca5854f8d5dea

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Minor fixes to registry memory management.
h3rald h3rald@h3rald.com
Wed, 10 Sep 2025 17:22:18 +0200
commit

ad7bd4bfe43a6167901548d506eca5854f8d5dea

parent

5a581f4cad677be1b04bc390d3ed0e7821e1403f

2 files changed, 12 insertions(+), 12 deletions(-)

jump to
M src/hex.csrc/hex.c

@@ -1189,17 +1189,17 @@ while (entry != NULL)

{ if (strcmp(entry->key, key) == 0) { - // Key found, copy the value to result - HEX_ALLOC(item); - item = hex_copy_item(ctx, entry->value); // Copy the value structure - if (item == NULL) + // Deep copy registry value into caller-provided storage (no aliasing) + hex_item_t *copy = hex_copy_item(ctx, entry->value); + if (!copy) { hex_error(ctx, "[get symbol] Failed to copy item for key: %s", key); return 0; } - *result = *item; + *result = *copy; // Move struct contents + free(copy); // Free wrapper; inner allocations now owned by result hex_debug_item(ctx, "DONE", result); - return 1; // Success + return 1; } entry = entry->next; // Move to the next entry in the bucket }
M src/registry.csrc/registry.c

@@ -226,17 +226,17 @@ while (entry != NULL)

{ if (strcmp(entry->key, key) == 0) { - // Key found, copy the value to result - HEX_ALLOC(item); - item = hex_copy_item(ctx, entry->value); // Copy the value structure - if (item == NULL) + // Deep copy registry value into caller-provided storage (no aliasing) + hex_item_t *copy = hex_copy_item(ctx, entry->value); + if (!copy) { hex_error(ctx, "[get symbol] Failed to copy item for key: %s", key); return 0; } - *result = *item; + *result = *copy; // Move struct contents + free(copy); // Free wrapper; inner allocations now owned by result hex_debug_item(ctx, "DONE", result); - return 1; // Success + return 1; } entry = entry->next; // Move to the next entry in the bucket }