Skip to content

Commit

Permalink
Merge pull request #1127 from prj-2501/main
Browse files Browse the repository at this point in the history
Div-by-zero and nullptr-deref fixes
  • Loading branch information
ahrm authored Jul 17, 2024
2 parents b72c3e0 + c31871d commit 277aed7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pdf_viewer/main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,14 @@ void MainWidget::open_document(const Path& path, std::optional<float> offset_x,
show_password_prompt_if_required();

if (main_document_view_has_document()) {
if (doc()->num_pages() > 0) {
scroll_bar->setSingleStep(std::max(MAX_SCROLLBAR / doc()->num_pages() / 10, 1));
scroll_bar->setPageStep(MAX_SCROLLBAR / doc()->num_pages());
update_scrollbar();
} else {
scroll_bar->setSingleStep(1);
scroll_bar->setPageStep(10);
}
update_scrollbar();
}


Expand Down Expand Up @@ -1585,6 +1590,10 @@ bool MainWidget::find_location_of_text_under_pointer(WindowPos pointer_pos, int*
int current_page_number = get_current_page_number();

fz_stext_page* stext_page = main_document_view->get_document()->get_stext_with_page_number(page);
if (!stext_page) {
// can happen if the reference was stale (e.g. file got overwritten etc.)
return false;
}
std::vector<fz_stext_char*> flat_chars;
get_flat_chars_from_stext_page(stext_page, flat_chars);

Expand Down

0 comments on commit 277aed7

Please sign in to comment.