diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2025-04-02 11:29:39 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2025-04-07 19:38:47 +0200 |
commit | c5ac2f1975e33fb5c665e700a411329fad384f4d (patch) | |
tree | 5884ea729db909c1d5ad9a72f57df4ce2126c35a | |
parent | 2cba4774520065d81685fa5c9a5b2a967a363594 (diff) |
Bug 708397: Fix the fix for pdf_delete_page_range.
End of the range for exclusive loop is "count", not "count+1".
Clamp both start and end values to be in range.
-rw-r--r-- | source/pdf/pdf-page.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 0828ec7bb..808864358 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -1492,11 +1492,10 @@ void pdf_delete_page_range(fz_context *ctx, pdf_document *doc, int start, int end) { int count = pdf_count_pages(ctx, doc); - - if (end < 0 || end > count) - end = count+1; - if (start < 0) - start = 0; + if (end < 0) + end = count; + start = fz_clampi(start, 0, count); + end = fz_clampi(end, 0, count); while (start < end) { pdf_delete_page(ctx, doc, start); |