From 0d671d4364fa0db76fca6584a97c51de02b9e220 Mon Sep 17 00:00:00 2001 From: A404M Date: Wed, 28 May 2025 13:52:10 +0330 Subject: add more stuff to lib fix use after free --- src/compiler/ast-tree.c | 9 ++++++--- src/runner/runner.c | 30 ++++++++++++++---------------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index 0b4bc63..fc9217e 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -5639,9 +5639,12 @@ bool setTypesFunctionCall(AstTree *tree, AstTreeSetTypesHelper _helper) { AstTreeFunctionCallParam p0 = metadata->parameters[i]; AstTreeFunctionCallParam p1 = call->parameters[i]; - AstTree *v0 = getValue(p0.value, false); - AstTree *v1 = getValue(p1.value, false); - if (!isEqual(v0, v1)) { + AstTree *v0 = getValue(p0.value, true); + AstTree *v1 = getValue(p1.value, true); + bool res = isEqual(v0, v1); + astTreeDelete(v0); + astTreeDelete(v1); + if (!res) { goto SEARCH_LOOP_CONTINUE; } } diff --git a/src/runner/runner.c b/src/runner/runner.c index b41e0db..a952c0b 100644 --- a/src/runner/runner.c +++ b/src/runner/runner.c @@ -1418,13 +1418,11 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, astTreeDelete(condition); AstTree *ret; if (condi) { - ret = - runExpression(metadata->ifBody, scope, shouldRet, isLeft, isComptime, - breakCount, shouldContinue, false); + ret = runExpression(metadata->ifBody, scope, shouldRet, isLeft, + isComptime, breakCount, shouldContinue, false); } else if (metadata->elseBody != NULL) { - ret = - runExpression(metadata->elseBody, scope, shouldRet, isLeft, - isComptime, breakCount, shouldContinue, false); + ret = runExpression(metadata->elseBody, scope, shouldRet, isLeft, + isComptime, breakCount, shouldContinue, false); } else { ret = &AST_TREE_VOID_VALUE; } @@ -1472,10 +1470,9 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, AstTree *ret = &AST_TREE_VOID_VALUE; for (size_t i = 0; i < metadata->expressions_size && !*shouldRet; ++i) { astTreeDelete(ret); - ret = - runExpression(metadata->expressions[i], scope, shouldRet, - i == metadata->expressions_size - 1 && isLeft, - isComptime, breakCount, shouldContinue, false); + ret = runExpression(metadata->expressions[i], scope, shouldRet, + i == metadata->expressions_size - 1 && isLeft, + isComptime, breakCount, shouldContinue, false); if (discontinue(*shouldRet, *breakCount)) { return ret; } @@ -1502,9 +1499,9 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, for (size_t i = 0; i < 1; ++i) { AstTreeVariable *arg = fun->arguments.data[i]; - arguments[i] = getForVariable(arguments[i], scope, shouldRet, isLeft, - isComptime, breakCount, shouldContinue, - arg->isLazy, false); + arguments[i] = + getForVariable(arguments[i], scope, shouldRet, isLeft, isComptime, + breakCount, shouldContinue, arg->isLazy, false); if (discontinue(*shouldRet, *breakCount)) { astTreeDelete(function); for (size_t j = 0; j < i; ++j) { @@ -1553,9 +1550,9 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, for (size_t i = 0; i < 2; ++i) { AstTreeVariable *arg = fun->arguments.data[i]; - arguments[i] = getForVariable(arguments[i], scope, shouldRet, isLeft, - isComptime, breakCount, shouldContinue, - arg->isLazy, false); + arguments[i] = + getForVariable(arguments[i], scope, shouldRet, isLeft, isComptime, + breakCount, shouldContinue, arg->isLazy, false); if (discontinue(*shouldRet, *breakCount)) { astTreeDelete(function); for (size_t j = 0; j < i; ++j) { @@ -1649,6 +1646,7 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, } if (operand->token != AST_TREE_TOKEN_RAW_VALUE_NOT_OWNED) { + printLog("%s", AST_TREE_TOKEN_STRINGS[operand->token]); UNREACHABLE; } -- cgit v1.2.3