mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 22:53:47 +01:00
Make sure we do not underflow
This commit is contained in:
parent
badc0e2815
commit
4c88e9d1ef
@ -69,7 +69,12 @@ position_to_page_number(zathura_document_t* document, double pos_x,
|
||||
unsigned int col = floor(pos_x * (double)doc_width / (double)(cell_width + pad));
|
||||
unsigned int row = floor(pos_y * (double)doc_height / (double)(cell_height + pad));
|
||||
|
||||
return ncol * (row % nrow) + (col % ncol) - (c0 - 1);
|
||||
unsigned int page = ncol * (row % nrow) + (col % ncol);
|
||||
if (page < c0 - 1) {
|
||||
return 0;
|
||||
} else {
|
||||
return page - (c0 - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user