[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-poppler
Subject:    [poppler] poppler/Annot.cc
From:       gitlab-mirror () kemper ! freedesktop ! org (GitLab Mirror)
Date:       2019-09-27 15:04:09
Message-ID: 20190927150409.B603B761AB () kemper ! freedesktop ! org
[Download RAW message or body]

 poppler/Annot.cc |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit cec2397fc0542516cac16615f63ab89032806a2e
Author: Albert Astals Cid <aacid@kde.org>
Date:   Fri Sep 27 16:56:33 2019 +0200

    Annot: Protect against division by 0.0

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index b51eeae4..56b9b933 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -4084,7 +4084,7 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
   GooString convertedText;
   const GfxFont *font;
   double dx, dy;
-  double fontSize, fontSize2, borderWidth, x, xPrev, y, w, wMax;
+  double fontSize, borderWidth, x, xPrev, y, w, wMax;
   int tfPos, tmPos, j;
   int rot;
   bool freeText = false;      // true if text should be freed before return
@@ -4415,9 +4415,11 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
       // compute font autosize
       if (fontSize == 0) {
         fontSize = dy - 2 * borderWidth;
-        fontSize2 = (dx - 4 - 2 * borderWidth) / w;
-        if (fontSize2 < fontSize) {
-          fontSize = fontSize2;
+        if (w > 0) {
+          const double fontSize2 = (dx - 4 - 2 * borderWidth) / w;
+          if (fontSize2 < fontSize) {
+            fontSize = fontSize2;
+          }
         }
         fontSize = floor(fontSize);
         if (tfPos >= 0) {
@@ -4499,7 +4501,7 @@ bool AnnotAppearanceBuilder::drawListBox(const FormFieldChoice *fieldChoice, con
   GooString *tok;
   GooString convertedText;
   const GfxFont *font;
-  double fontSize, fontSize2, borderWidth, x, y, w, wMax;
+  double fontSize, borderWidth, x, y, w, wMax;
   int tfPos, tmPos, i, j;
 
   //~ if there is no MK entry, this should use the existing content stream,
@@ -4585,7 +4587,7 @@ bool AnnotAppearanceBuilder::drawListBox(const FormFieldChoice *fieldChoice, con
       }
     }
     fontSize = rect->y2 - rect->y1 - 2 * borderWidth;
-    fontSize2 = (rect->x2 - rect->x1 - 4 - 2 * borderWidth) / wMax;
+    const double fontSize2 = (rect->x2 - rect->x1 - 4 - 2 * borderWidth) / wMax;
     if (fontSize2 < fontSize) {
       fontSize = fontSize2;
     }
_______________________________________________
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic