Created attachment 8049 [details] PostScript Language Reference Manual After selecting PLRM.pdf on a 1st generation iPad running iOS 4.3.3, it processes PLRM.pdf for a moment and then fails. The console messages say: applicationDidBecomeActive! open xref '/var/mobile/Applications/BCE161B2-EF18-4965-A23B-B0023B205B39/Documents/PLRM.pdf' loading page 0 for size 768 x 1004 fatal error: out of memory (integer overflow) The debugger stack says: Program received signal: “SIGABRT” [...] #0 0x33850a1c in __pthread_kill () #1 0x369413ba in pthread_kill () #2 0x36939bfe in abort () #3 0x00008b68 in fz_calloc (count=41041, size=130892) at fitz/base_memory.c:26 #4 0x0001f696 in fz_new_pixmap_with_data (colorspace=0x641de0, w=32723, h=41041, samples=0x0) at fitz/res_pixmap.c:38 #5 0x0001f81a in fz_new_pixmap (colorspace=0x641de0, w=32723, h=41041) at fitz/res_pixmap.c:62 #6 0x0001f870 in fz_new_pixmap_with_rect (colorspace=0x641de0, r={x0 = -35249, y0 = -41041, x1 = -2526, y1 = 0}) at fitz/res_pixmap.c:69 #7 0x00004446 in renderPage (xref=0x4424000, number=0, width=768, height=1004) at /Users/artford/ghostscript/tor/mupdf/ios/main.m:165 #8 0x00004042 in __35-[MuDocumentController reloadPage:]_block_invoke_0 (.block_descriptor=0x46e2b90) at /Users/artford/ghostscript/tor/mupdf/ios/main.m:427
Looks like the scale factors were off. The following resolved the problem: diff --git a/ios/main.m b/ios/main.m index 89614fc..1aeaa6e 100644 --- a/ios/main.m +++ b/ios/main.m @@ -153,8 +153,8 @@ static UIImage *renderPage(pdf_xref *xref, int number, float return nil; } - hscale = width / page->mediabox.x1 - page->mediabox.x0; - vscale = height / page->mediabox.y1 - page->mediabox.y0; + hscale = width / (page->mediabox.x1 - page->mediabox.x0); + vscale = height / (page->mediabox.y1 - page->mediabox.y0); scale = MIN(hscale, vscale); ctm = fz_translate(0, -page->mediabox.y1);
Gah! Thanks for spotting this!