From 7ff4d9f038d01cf62366bc3579731a86e7e58419 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 7 Mar 2011 00:29:39 +0000 Subject: Fix typo in pspush* and check for invalid input to under/overflow checks. --- mupdf/pdf_function.c | 13 ++++++++----- 1 file 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++; } } -- cgit v1.2.3