aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-15 00:04:44 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-15 00:04:44 +0330
commitabeb4953354b7afb57ea71cf63184afae2b30edd (patch)
treee85af368683852038866e7ad1d8b604033989440 /src
parentf9a3bdda45c7945adc9842264f9cf4d55cda18f2 (diff)
fix double free bug in global variables
Diffstat (limited to 'src')
-rw-r--r--src/runner/runner.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/runner/runner.c b/src/runner/runner.c
index a847327..a1251a2 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -139,8 +139,7 @@ bool runAstTree(AstTreeRoots roots) {
AstTreeVariable *mainVariable = NULL;
- AstTreeScope *scope = a404m_malloc(sizeof(*scope));
- *scope = (AstTreeScope){
+ AstTreeScope scope = {
.expressions = a404m_malloc(0),
.expressions_size = 0,
.variables.data = a404m_malloc(0),
@@ -165,7 +164,8 @@ bool runAstTree(AstTreeRoots roots) {
}
if (!variable->isConst) {
runnerVariableSetValueWihtoutConstCheck(variable, variable->initValue,
- scope);
+ &scope);
+ variable->initValue = NULL;
}
}
}
@@ -183,12 +183,11 @@ bool runAstTree(AstTreeRoots roots) {
return false;
}
- AstTree *res = runAstTreeFunction(main, NULL, 0, scope, false);
+ AstTree *res = runAstTreeFunction(main, NULL, 0, &scope, false);
const bool ret = res == &AST_TREE_VOID_VALUE;
astTreeDelete(res);
astTreeDelete(main);
- astTreeDelete(
- newAstTree(AST_TREE_TOKEN_SCOPE, scope, &AST_TREE_VOID_TYPE, NULL, NULL));
+ astTreeScopeDestroy(scope);
return ret;
}