all repos — hex @ cd562a3b9b76cb6760fd0b9b282fa9a097bf7ed4

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

Attempting to fix segmentation faults.
h3rald h3rald@h3rald.com
Wed, 21 May 2025 09:59:27 +0200
commit

cd562a3b9b76cb6760fd0b9b282fa9a097bf7ed4

parent

597c8ac3780e77fbbf6d1ce9c9688554935e3ee5

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

jump to
M lib/utils.hexlib/utils.hex

@@ -225,6 +225,7 @@ 0x0 "_sort_i" :

0x0 "_sort_j" : 0x0 "_sort_current" : 0x0 "_sort_next" : + 0x0 "_sort_swapped" : (_sort_i _sort_list len 0x1 - <=) ( (_sort_j _sort_list len _sort_i - 0x1 - <=)
M src/hex.csrc/hex.c

@@ -439,7 +439,7 @@ {

if (token == NULL || token->value == NULL) return; free(token->value); - token->value = NULL; + // token->value = NULL; free(token); // Free the token itself }

@@ -680,21 +680,19 @@ if (item->data.str_value)

{ hex_debug_item(ctx, "FREE", item); free(item->data.str_value); - item->data.str_value = NULL; // Prevent double free } free(item); // Free the item itself - item = NULL; + // item = NULL; break; case HEX_TYPE_QUOTATION: if (item->data.quotation_value) { - // hex_debug_item(ctx, "FREE", item); // May cause segfaults + hex_debug_item(ctx, "FREE", item); hex_free_list(ctx, item->data.quotation_value, item->quotation_size); - item->data.quotation_value = NULL; // Prevent double free + free(item->data.quotation_value); // Free the array of items } free(item); // Free the item itself - item = NULL; break; case HEX_TYPE_NATIVE_SYMBOL:

@@ -747,7 +745,7 @@ }

} else { - copy->value = NULL; + // copy->value = NULL; } // Copy the file position if it exists

@@ -867,7 +865,6 @@ copy->data.quotation_value[i] = hex_copy_item(ctx, item->data.quotation_value[i]); // Recursively copy each item

if (!copy->data.quotation_value[i]) { // Cleanup on failure - hex_free_list(ctx, copy->data.quotation_value, i); // Free copied items hex_free_item(ctx, copy); hex_error(ctx, "[copy item] Failed to copy quotation item"); return NULL;
M src/stack.csrc/stack.c

@@ -12,7 +12,7 @@ {

if (token == NULL || token->value == NULL) return; free(token->value); - token->value = NULL; + // token->value = NULL; free(token); // Free the token itself }

@@ -253,10 +253,9 @@ if (item->data.str_value)

{ hex_debug_item(ctx, "FREE", item); free(item->data.str_value); - item->data.str_value = NULL; // Prevent double free } free(item); // Free the item itself - item = NULL; + // item = NULL; break; case HEX_TYPE_QUOTATION:

@@ -264,10 +263,9 @@ if (item->data.quotation_value)

{ hex_debug_item(ctx, "FREE", item); hex_free_list(ctx, item->data.quotation_value, item->quotation_size); - item->data.quotation_value = NULL; // Prevent double free + free(item->data.quotation_value); // Free the array of items } free(item); // Free the item itself - item = NULL; break; case HEX_TYPE_NATIVE_SYMBOL:

@@ -440,7 +438,6 @@ copy->data.quotation_value[i] = hex_copy_item(ctx, item->data.quotation_value[i]); // Recursively copy each item

if (!copy->data.quotation_value[i]) { // Cleanup on failure - hex_free_list(ctx, copy->data.quotation_value, i); // Free copied items hex_free_item(ctx, copy); hex_error(ctx, "[copy item] Failed to copy quotation item"); return NULL;