mupdf: exit earlier for broken pdf files
authorAli Gholami Rudi <ali@rudi.ir>
Mon, 18 Jun 2012 19:21:10 +0000 (18 23:51 +0430)
committerAli Gholami Rudi <ali@rudi.ir>
Mon, 18 Jun 2012 19:21:10 +0000 (18 23:51 +0430)
mupdf.c

diff --git a/mupdf.c b/mupdf.c
index d242ad3..a45d4d5 100644 (file)
--- a/mupdf.c
+++ b/mupdf.c
@@ -63,7 +63,7 @@ struct doc *doc_open(char *path)
        struct doc *doc = malloc(sizeof(*doc));
        doc->ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
        doc->pdf = fz_open_document(doc->ctx, path);
-       if (!doc->pdf) {
+       if (!doc->pdf || !fz_count_pages(doc->pdf)) {
                free(doc);
                return NULL;
        }