From b8126bfc033da43ad332e62f1c4ff6ec2662998e Mon Sep 17 00:00:00 2001 From: mbkma Date: Wed, 11 Mar 2026 22:59:56 +0100 Subject: fix some memory leaks reported by valgrind --- src/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/parser.c') 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); } -- cgit v1.2.1