[poppler] poppler/Catalog.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jul 23 14:08:55 UTC 2023


 poppler/Catalog.cc |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit d8d63630427ca39da995e148fc1a80010c1804f9
Author: Ilaï Deutel <idtl at google.com>
Date:   Wed Jul 19 19:07:54 2023 -0400

    Fix float-cast-overflow error in Catalog
    
    This error was triggered when running the page_label_fuzzer using https://github.com/mozilla/pdf.js/blob/master/test/pdfs/poppler-67295-0.pdf as an input.
    
    The fix avoids extraneous casts in Catalog.cc:
    
    - Before:
      - int -> double -> int
      - long long -> double -> int
      - double -> int
    - After:
      - int (no cast)
      - long long -> int
      - double -> int

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 7a1e4095..05807558 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -875,7 +875,13 @@ int Catalog::getNumPages()
                 numPages = 0;
             }
         } else {
-            numPages = (int)obj.getNum();
+            if (obj.isInt()) {
+                numPages = obj.getInt();
+            } else if (obj.isInt64()) {
+                numPages = obj.getInt64();
+            } else {
+                numPages = obj.getNum();
+            }
             if (numPages <= 0) {
                 error(errSyntaxError, -1, "Invalid page count {0:d}", numPages);
                 numPages = 0;


More information about the poppler mailing list