libCom: Fix buggy pointer dereference in postfix()

This commit is contained in:
Jeremy Lorelli
2023-07-18 16:24:37 -07:00
committed by Dirk Zimoch
parent e291ca0a03
commit 67e669c5e5
2 changed files with 11 additions and 1 deletions

View File

@@ -336,6 +336,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) {
@@ -354,6 +358,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) {