summaryrefslogtreecommitdiff
path: root/src/parserfunc.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-03-16 00:21:35 +0100
committerGitHub <[email protected]>2020-03-16 00:21:35 +0100
commite92e709de7d9b92cff1c1d94ddc26ebb7699cc62 (patch)
treec82b72198a1fd5a3a7c66e0f09b3e5319f103d93 /src/parserfunc.c
parentab02da75a6bd398c23a035354848100687d54dc1 (diff)
downloadmate-calc-e92e709de7d9b92cff1c1d94ddc26ebb7699cc62.tar.bz2
mate-calc-e92e709de7d9b92cff1c1d94ddc26ebb7699cc62.tar.xz
parserfunc: fix crash when calculating nested pow
Diffstat (limited to 'src/parserfunc.c')
-rw-r--r--src/parserfunc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/parserfunc.c b/src/parserfunc.c
index 8f153aa..4ef55d2 100644
--- a/src/parserfunc.c
+++ b/src/parserfunc.c
@@ -587,7 +587,18 @@ pf_do_x_pow_y_int(ParseNode* self)
gint pow;
MPNumber* ans = mp_new_ptr();
val = (MPNumber*) (*(self->left->evaluate))(self->left);
- pow = super_atoi(self->right->token->string);
+
+ if(!val)
+ {
+ val = mp_new_ptr();
+ mp_set_from_integer(super_atoi(self->left->token->string), val);
+ }
+
+ if (self->right->token != NULL)
+ pow = super_atoi(self->right->token->string);
+ else
+ pow = mp_to_integer((MPNumber*) (*(self->right->evaluate))(self->right));
+
if(!val)
{
mp_free(ans);