all repos — hex @ 5345e120e649bff689a2a493ae3e1b4ab9ffbe50

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

Fixes.
h3rald h3rald@h3rald.com
Thu, 21 Nov 2024 13:36:02 +0100
commit

5345e120e649bff689a2a493ae3e1b4ab9ffbe50

parent

85ad7c710e45e83310d5c9747cd3a3450df64963

1 files changed, 20 insertions(+), 1 deletions(-)

jump to
M hex.chex.c

@@ -278,6 +278,7 @@ return result;

} else if (element.type == HEX_TYPE_NATIVE_SYMBOL) { + hex_debug_element("CALL", element); return element.data.functionPointer(); } HEX_STACK[++HEX_TOP] = element;

@@ -3323,12 +3324,30 @@ HEX_StackElement evalResult = hex_pop();

if (evalResult.type == HEX_TYPE_INTEGER && evalResult.data.intValue > 0) { quotation[count] = (HEX_StackElement *)malloc(sizeof(HEX_StackElement)); + if (!quotation[count]) + { + hex_error("Memory allocation failed"); + result = 1; + break; + } *quotation[count] = *list.data.quotationValue[i]; count++; } hex_free_element(evalResult); } - result = hex_push_quotation(quotation, count); + if (result == 0) + { + result = hex_push_quotation(quotation, count); + } + else + { + hex_error("An error occurred while filtering the list"); + result = 1; + for (size_t i = 0; i < count; i++) + { + hex_free_element(*quotation[i]); + } + } } } hex_free_element(list);