From: Toni Wilen Date: Sun, 14 May 2023 17:29:23 +0000 (+0300) Subject: Fix calculator memory double free X-Git-Tag: 5.0.0~46 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=55f7ff0427669628fee0324e1a90a5ca6bbd2518;p=francis%2Fwinuae.git Fix calculator memory double free --- diff --git a/calc.cpp b/calc.cpp index eaa10fd9..d1812203 100644 --- a/calc.cpp +++ b/calc.cpp @@ -548,7 +548,8 @@ static bool execution_order(const TCHAR *input, double *outval, TCHAR *outstring stack[sl].val = val; xfree(stack[sl].vals); stack[sl].vals = my_strdup(vals); - stack[sl].s = NULL; + xfree(stack[sl].s); + stack[sl].s = NULL; ++sl; } ++strpos; @@ -569,8 +570,12 @@ static bool execution_order(const TCHAR *input, double *outval, TCHAR *outstring } ok = true; } - for (i = 0; i < STACK_SIZE; i++) - xfree (stack[i].s); + for (i = 0; i < STACK_SIZE; i++) { + xfree(stack[i].s); + stack[i].s = NULL; + xfree(stack[i].vals); + stack[i].vals = NULL; + } // If there are more values in the stack // (Error) The user input has too many values.