cmd: Fix memory leak in WCMD_reduce.

Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Lauri Kenttä 2016-12-17 10:33:27 +02:00 committed by Alexandre Julliard
parent 0ea8893e1c
commit 21dd04670c
1 changed files with 8 additions and 10 deletions

View File

@ -3689,7 +3689,7 @@ static WCHAR WCMD_popoperator(OPSTACK **opstack) {
* Returns non-zero on error. * Returns non-zero on error.
*/ */
static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) { static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
OPSTACK *thisop; WCHAR thisop;
int var1,var2; int var1,var2;
int rc = 0; int rc = 0;
@ -3699,13 +3699,12 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
} }
/* Remove the top operator */ /* Remove the top operator */
thisop = *opstack; thisop = WCMD_popoperator(opstack);
*opstack = (*opstack)->next; WINE_TRACE("Reducing the stacks - processing operator %c\n", thisop);
WINE_TRACE("Reducing the stacks - processing operator %c\n", thisop->op);
/* One variable operators */ /* One variable operators */
var1 = WCMD_popnumber(varstack); var1 = WCMD_popnumber(varstack);
switch (thisop->op) { switch (thisop) {
case '!': WCMD_pushnumber(NULL, !var1, varstack); case '!': WCMD_pushnumber(NULL, !var1, varstack);
break; break;
case '~': WCMD_pushnumber(NULL, ~var1, varstack); case '~': WCMD_pushnumber(NULL, ~var1, varstack);
@ -3721,7 +3720,7 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
WINE_TRACE("No operands left for the reduce?\n"); WINE_TRACE("No operands left for the reduce?\n");
return WCMD_NOOPERAND; return WCMD_NOOPERAND;
} }
switch (thisop->op) { switch (thisop) {
case '!': case '!':
case '~': case '~':
case OP_POSITIVE: case OP_POSITIVE:
@ -3792,11 +3791,11 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
/* Make the operand stack grow by pushing the assign operator plus the /* Make the operand stack grow by pushing the assign operator plus the
operator to perform */ operator to perform */
while (calcassignments[i].op != ' ' && while (calcassignments[i].op != ' ' &&
calcassignments[i].calculatedop != thisop->op) { calcassignments[i].calculatedop != thisop) {
i++; i++;
} }
if (calcassignments[i].calculatedop == ' ') { if (calcassignments[i].calculatedop == ' ') {
WINE_ERR("Unexpected operator %c\n", thisop->op); WINE_ERR("Unexpected operator %c\n", thisop);
return WCMD_NOOPERATOR; return WCMD_NOOPERATOR;
} }
WCMD_pushoperator('=', WCMD_getprecedence('='), opstack); WCMD_pushoperator('=', WCMD_getprecedence('='), opstack);
@ -3820,10 +3819,9 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
break; break;
} }
default: WINE_ERR("Unrecognized operator %c\n", thisop->op); default: WINE_ERR("Unrecognized operator %c\n", thisop);
} }
heap_free(thisop);
return rc; return rc;
} }