From 2c0583ae9e3e2a25551e559aa9a0864ee574137a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 15 Jul 2006 21:40:05 +0200 Subject: implicitely end setup section if %%Page comment is encountered check for valid setup length after DSC parsing --- src/PostscriptDSC.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/PostscriptDSC.cxx b/src/PostscriptDSC.cxx index 85a9d5b..806a418 100644 --- a/src/PostscriptDSC.cxx +++ b/src/PostscriptDSC.cxx @@ -95,6 +95,11 @@ PostscriptDSC::parse(int fd) { } else if (strncmp(linebuf, "%%Page: ", strlen("%%Page: ")) == 0) { char *p_str = &linebuf[strlen(linebuf)]; + // implicitely end setup section + if (!setup_len) { + setup_len = ftello(fp); + } + // move p_str back to beginning of last number in linebuf while (p_str > linebuf && !isdigit(*p_str)) { p_str--; @@ -137,7 +142,12 @@ PostscriptDSC::parse(int fd) { } } } - + + // Now do some checks + if (!setup_len) { + fprintf(stderr, "PageSetup end not found\n"); + return 1; + } if (page_len && page_off && p1 > 0 && p1 <= pages) { page_len[p1 - 1] = ftello(fp) - page_off[p1 - 1]; -- cgit v1.2.3