libCom: Fix buggy pointer dereference in postfix()

This commit is contained in:
Jeremy Lorelli
2023-07-18 16:24:37 -07:00
committed by Michael Davidsaver
parent 88ea1507f4
commit 60fa2d31da
2 changed files with 11 additions and 1 deletions

View File

@@ -335,6 +335,10 @@ LIBCOM_API long
break;
case SEPERATOR:
if (pstacktop == stack) {
*perror = CALC_ERR_BAD_SEPERATOR;
goto bad;
}
/* Move operators to the output until open paren */
while (pstacktop->name[0] != '(') {
if (pstacktop <= stack+1) {
@@ -353,6 +357,10 @@ LIBCOM_API long
break;
case CLOSE_PAREN:
if (pstacktop == stack) {
*perror = CALC_ERR_PAREN_NOT_OPEN;
goto bad;
}
/* Move operators to the output until matching paren */
while (pstacktop->name[0] != '(') {
if (pstacktop <= stack+1) {