From e89f86def4bbd01456e8a48dd0f5463deff5ea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Fox?= Date: Sun, 15 Nov 2026 18:34:01 +0100 Subject: [PATCH] ev-print-operation.c: Reject page ranges outside the document clamp_ranges dropped ranges that start past the last page but still returned TRUE when none were left, so printing went on with zero ranges and read past the ranges array. It also counted the dropped ranges in n_pages_to_print. Skip them in the count and treat an empty result as an invalid selection. --- libview/ev-print-operation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libview/ev-print-operation.c b/libview/ev-print-operation.c index 663026b1..dca2c2ac 100644 --- a/libview/ev-print-operation.c +++ b/libview/ev-print-operation.c @@ -622,6 +622,8 @@ clamp_ranges (EvPrintOperationExport *export) export->ranges[i].start = 0; export->ranges[num_of_correct_ranges] = export->ranges[i]; num_of_correct_ranges++; + } else { + continue; } n_pages = export->ranges[i].end - export->ranges[i].start + 1; @@ -644,7 +646,7 @@ clamp_ranges (EvPrintOperationExport *export) } } - if (null_flag && !n_pages_to_print) { + if (num_of_correct_ranges == 0 || (null_flag && !n_pages_to_print)) { return FALSE; } else { export->n_ranges = num_of_correct_ranges;