diff --git a/zathura/document.c b/zathura/document.c index 7ed9acb..d094e2e 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -518,8 +518,13 @@ zathura_document_get_document_size(zathura_document_t* document, { g_return_if_fail(document != NULL && height != NULL && width != NULL); - const unsigned int npag = zathura_document_get_number_of_pages(document); - const unsigned int ncol = zathura_document_get_pages_per_row(document); + const unsigned int npag = zathura_document_get_number_of_pages(document); + const unsigned int ncol = zathura_document_get_pages_per_row(document); + + if (npag == 0 || ncol == 0) { + return; + } + const unsigned int c0 = zathura_document_get_first_page_column(document); const unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */ const unsigned int pad = zathura_document_get_page_padding(document); diff --git a/zathura/zathura.c b/zathura/zathura.c index 8712c8a..8c493ae 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -791,8 +791,6 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char* goto error_out; } - zathura->document = document; - const char* file_path = zathura_document_get_path(document); unsigned int number_of_pages = zathura_document_get_number_of_pages(document); @@ -802,6 +800,8 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char* goto error_free; } + zathura->document = document; + /* read history file */ zathura_fileinfo_t file_info = { .current_page = 0,