diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-06 15:07:52 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-06 15:10:59 +0200 |
commit | 9c021377135a931a11bab58d6fe30353a98f1092 (patch) | |
tree | d07a37e1b93c0311e26b4f4d9bd38dffdccd3816 | |
parent | 2f9a718a565195f3bd28a283ab372be8b4430f00 (diff) | |
download | mupdf-9c021377135a931a11bab58d6fe30353a98f1092.tar.xz |
Check for a display list before trying to render it in pdfapp
Previously fix 13943b92f10796efb175e769afe5b0aea85d879a introduced
continued rendering of further pages for documents where one page
failed to load. However, if the entire page tree was missing from a
PDF document then no display list would be obtained, yet MuPDF tried
to render the display list causing a null pointer dereference. Now,
check for a valid display list before trying to render it.
-rw-r--r-- | apps/pdfapp.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 50a89610..1a17e172 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -326,9 +326,12 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai /* Extract text */ app->page_sheet = fz_new_text_sheet(app->ctx); app->page_text = fz_new_text_page(app->ctx, app->page_bbox); - tdev = fz_new_text_device(app->ctx, app->page_sheet, app->page_text); - fz_run_display_list(app->page_list, tdev, fz_identity, fz_infinite_bbox, &cookie); - fz_free_device(tdev); + if (app->page_list) + { + tdev = fz_new_text_device(app->ctx, app->page_sheet, app->page_text); + fz_run_display_list(app->page_list, tdev, fz_identity, fz_infinite_bbox, &cookie); + fz_free_device(tdev); + } } if (drawpage) @@ -365,9 +368,12 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai #endif app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, bbox); fz_clear_pixmap_with_value(app->ctx, app->image, 255); - idev = fz_new_draw_device(app->ctx, app->image); - fz_run_display_list(app->page_list, idev, ctm, bbox, &cookie); - fz_free_device(idev); + if (app->page_list) + { + idev = fz_new_draw_device(app->ctx, app->image); + fz_run_display_list(app->page_list, idev, ctm, bbox, &cookie); + fz_free_device(idev); + } if (app->invert) fz_invert_pixmap(app->ctx, app->image); } |