From bea63dc6c468deb4b0a559070adc33888b9561c3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 May 2023 16:27:57 +0530 Subject: [PATCH] Fix delete_pages() --- src/calibre/utils/podofo/doc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/utils/podofo/doc.cpp b/src/calibre/utils/podofo/doc.cpp index 9272fc5739..9129f6c816 100644 --- a/src/calibre/utils/podofo/doc.cpp +++ b/src/calibre/utils/podofo/doc.cpp @@ -239,12 +239,11 @@ PDFDoc_image_count(PDFDoc *self, PyObject *args) { // delete_page() {{{ static PyObject * PDFDoc_delete_pages(PDFDoc *self, PyObject *args) { - int page = 0, count = 1; - if (PyArg_ParseTuple(args, "i|i", &page, &count)) { + unsigned int page, count = 1; + if (PyArg_ParseTuple(args, "I|I", &page, &count)) { try { - while (count > 0) { - self->doc->GetPages().RemovePageAt(page - 1); - } + auto &pages = self->doc->GetPages(); + while (count-- > 0) pages.RemovePageAt(page - 1); } catch(const PdfError & err) { podofo_set_exception(err); return NULL;