From cfc5418931fa15e6a31583820266bf35d489da88 Mon Sep 17 00:00:00 2001 From: A404M Date: Sat, 17 May 2025 16:19:33 +0330 Subject: fix memory leaks and shape shifter --- src/runner/runner.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/runner/runner.c') diff --git a/src/runner/runner.c b/src/runner/runner.c index 0fbfbf2..67fc02e 100644 --- a/src/runner/runner.c +++ b/src/runner/runner.c @@ -1096,19 +1096,26 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, function->token <= AST_TREE_TOKEN_BUILTIN_END) { for (size_t i = 0; i < args_size; ++i) { AstTreeFunctionCallParam param = metadata->parameters[i]; - args[i] = getForVariable(param.value, scope, shouldRet, false, - isComptime, breakCount, shouldContinue, false); - if (discontinue(*shouldRet, *breakCount)) { - astTreeDelete(function); - for (size_t j = 0; j < i; ++j) { - astTreeDelete(args[i]); + if (function->token != AST_TREE_TOKEN_BUILTIN_TYPE_OF) { + args[i] = + getForVariable(param.value, scope, shouldRet, false, isComptime, + breakCount, shouldContinue, false); + if (discontinue(*shouldRet, *breakCount)) { + astTreeDelete(function); + for (size_t j = 0; j < i; ++j) { + astTreeDelete(args[i]); + } + return args[i]; } - return args[i]; + } else { + args[i] = param.value; } } result = runAstTreeBuiltin(function, scope, args); - for (size_t i = 0; i < args_size; ++i) { - astTreeDelete(args[i]); + if (function->token != AST_TREE_TOKEN_BUILTIN_TYPE_OF) { + for (size_t i = 0; i < args_size; ++i) { + astTreeDelete(args[i]); + } } } else { UNREACHABLE; -- cgit v1.2.3