summaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2026-03-11 22:59:56 +0100
committerVictor Kareh <[email protected]>2026-03-12 12:27:17 -0400
commitb8126bfc033da43ad332e62f1c4ff6ec2662998e (patch)
treea12525469c563005867466a7768ee5ed877ae765 /src/parser.c
parentaeaa5450f8fa4e70aeea00eed02191106fe26705 (diff)
downloadmate-calc-b8126bfc033da43ad332e62f1c4ff6ec2662998e.tar.bz2
mate-calc-b8126bfc033da43ad332e62f1c4ff6ec2662998e.tar.xz
fix some memory leaks reported by valgrindHEADmaster
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c
index c9d711b..6aeba9e 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -238,6 +238,7 @@ p_create_parser(const gchar* input, MPEquationOptions* options)
state->options = options;
state->error = 0;
state->error_token = NULL;
+ state->ret = mp_new();
return state;
}
@@ -276,7 +277,6 @@ p_parse(ParserState* state)
ans = (MPNumber *) (*(state->root->evaluate))(state->root);
if(ans)
{
- state->ret = mp_new();
mp_set_from_mp(ans, &state->ret);
mp_free(ans);
return PARSER_ERR_NONE;
@@ -294,6 +294,8 @@ p_destroy_parser(ParserState* state)
p_destroy_all_nodes(state->root);
}
l_destroy_lexer(state->lexer);
+ mp_clear(&state->ret);
+ free(state->error_token);
free(state);
}