diff options
author | mbkma <[email protected]> | 2025-08-14 17:22:01 +0200 |
---|---|---|
committer | mbkma <[email protected]> | 2025-08-14 17:23:03 +0200 |
commit | 1d59ba9f01d29fe2c9f0591a09c9def682a4a614 (patch) | |
tree | 6b66982688e9cabfaa587e03de3e8b652072d8a3 /src/parser.c | |
parent | 7ef327f6f269c7a49357e001cd41d7aaf5807749 (diff) | |
download | mate-calc-fix/#213.tar.bz2 mate-calc-fix/#213.tar.xz |
fix Expressions like e²3 crashes mate-calcfix/#213
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c index d60c142..2cce157 100644 --- a/src/parser.c +++ b/src/parser.c @@ -219,8 +219,13 @@ p_destroy_all_nodes(ParseNode* node) p_destroy_all_nodes(node->right); /* Don't call free for tokens, as they are allocated and freed in lexer. */ /* WARNING: If node->value is freed elsewhere, please assign it NULL before calling p_destroy_all_nodes(). */ - if(node->value) + /* Fix for crash in expressions like "e²3" where node->value may be invalid */ + if(node->value && node->value != (void*)node->token) + { + /* Only free if value was dynamically allocated by parser functions */ + /* Skip freeing if value points to token data or other non-malloc'd memory */ free(node->value); + } free(node); } |