all repos — hex @ afefe4f80bd3f9881c93b36275199ada0a4c9022

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

Added workaround to prevent errors when freeing nested quoations.
h3rald h3rald@h3rald.com
Wed, 21 May 2025 15:31:12 +0200
commit

afefe4f80bd3f9881c93b36275199ada0a4c9022

parent

400f2ed70d5e4b1adf29633f09dd68320b0e4e11

2 files changed, 9 insertions(+), 3 deletions(-)

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

@@ -659,6 +659,7 @@ return;

for (size_t i = 0; i < size; i++) { + printf("===> %zu \n", i); if (quotation[i]) { hex_debug(ctx, "FREE: item #%zu", i);

@@ -689,7 +690,9 @@

case HEX_TYPE_QUOTATION: if (item->data.quotation_value) { - hex_debug_item(ctx, "FREE", item); + hex_debug(ctx, "FREE: freeing quotation (%zu items)", item->quotation_size); + // Temporarily comment out the free to avoid double free (probably need refcounting instead) + // This happens in case of nested quotations, e.g. a failure in a nested quotation // hex_free_list(ctx, item->data.quotation_value, item->quotation_size); free(item->data.quotation_value); // Free the array of items item->data.quotation_value = NULL; // Set to NULL to avoid double free
M src/stack.csrc/stack.c

@@ -232,6 +232,7 @@ return;

for (size_t i = 0; i < size; i++) { + printf("===> %zu \n", i); if (quotation[i]) { hex_debug(ctx, "FREE: item #%zu", i);

@@ -262,8 +263,10 @@

case HEX_TYPE_QUOTATION: if (item->data.quotation_value) { - hex_debug_item(ctx, "FREE", item); - hex_free_list(ctx, item->data.quotation_value, item->quotation_size); + hex_debug(ctx, "FREE: freeing quotation (%zu items)", item->quotation_size); + // Temporarily comment out the free to avoid double free (probably need refcounting instead) + // This happens in case of nested quotations, e.g. a failure in a nested quotation + // hex_free_list(ctx, item->data.quotation_value, item->quotation_size); free(item->data.quotation_value); // Free the array of items item->data.quotation_value = NULL; // Set to NULL to avoid double free }