summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2011-03-07 00:29:39 +0000
committerTor Andersson <tor@ghostscript.com>2011-03-07 00:29:39 +0000
commit7ff4d9f038d01cf62366bc3579731a86e7e58419 (patch)
tree27bb170c94b9c34a12e1b9c15ac20f599545e9be
parent073d9a2bf73551a3ea5e1314b283ba474eb55b1c (diff)
downloadmupdf-7ff4d9f038d01cf62366bc3579731a86e7e58419.tar.xz
Fix typo in pspush* and check for invalid input to under/overflow checks.
-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++;
}
}