summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mupdf/pdf_function.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c
index 8c431204..28c52151 100644
--- a/mupdf/pdf_function.c
+++ b/mupdf/pdf_function.c
@@ -157,13 +157,13 @@ psinitstack(psstack *st)
static inline int
psoverflow(psstack *st, int n)
{
- return st->sp + n >= nelem(st->stack);
+ return n < 0 || st->sp + n >= nelem(st->stack);
}
static inline int
psunderflow(psstack *st, int n)
{
- return st->sp - n < 0;
+ return n < 0 || st->sp - n < 0;
}
static inline int
@@ -183,8 +183,9 @@ pspushbool(psstack *st, int b)
{
if (!psoverflow(st, 1))
{
- st->stack[st->sp++].type = PSBOOL;
+ st->stack[st->sp].type = PSBOOL;
st->stack[st->sp].u.b = b;
+ st->sp++;
}
}
@@ -193,8 +194,9 @@ pspushint(psstack *st, int n)
{
if (!psoverflow(st, 1))
{
- st->stack[st->sp++].type = PSINT;
+ st->stack[st->sp].type = PSINT;
st->stack[st->sp].u.i = n;
+ st->sp++;
}
}
@@ -203,8 +205,9 @@ pspushreal(psstack *st, float n)
{
if (!psoverflow(st, 1))
{
- st->stack[st->sp++].type = PSREAL;
+ st->stack[st->sp].type = PSREAL;
st->stack[st->sp].u.f = n;
+ st->sp++;
}
}