[poppler] poppler/Function.cc poppler/MarkedContentOutputDev.cc poppler/TextOutputDev.cc

William Bader williambader at hotmail.com
Sat Aug 20 02:55:28 UTC 2022



> -    if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || x1 != x1 || y1 != y1 || // IEEE way of checking for isnan
> -        w1 != w1 || h1 != h1) {
> +    if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1)) {

Would it be better to test isnan before using the values, like

if (std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1) || x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight) {


________________________________
From: poppler <poppler-bounces at lists.freedesktop.org> on behalf of GitLab Mirror <gitlab-mirror at kemper.freedesktop.org>
Sent: Friday, August 19, 2022 4:24 PM
To: poppler at lists.freedesktop.org <poppler at lists.freedesktop.org>
Subject: [poppler] poppler/Function.cc poppler/MarkedContentOutputDev.cc poppler/TextOutputDev.cc

poppler/Function.cc               |    4 ++--
 poppler/MarkedContentOutputDev.cc |    6 +++---
 poppler/TextOutputDev.cc          |    3 +--
 3 files changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 5bec49749b9a2a9b4779a977f673531b42470264
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Aug 19 22:20:17 2022 +0200

    We can use isnan now

diff --git a/poppler/Function.cc b/poppler/Function.cc
index b97ad71e..043ae8e9 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2006, 2008-2010, 2013-2015, 2017-2020 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008-2010, 2013-2015, 2017-2020, 2022 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
 // Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
@@ -463,7 +463,7 @@ void SampledFunction::transform(const double *in, double *out) const
     // map input values into sample array
     for (int i = 0; i < m; ++i) {
         x = (in[i] - domain[i][0]) * inputMul[i] + encode[i][0];
-        if (x < 0 || x != x) { // x!=x is a more portable version of isnan(x)
+        if (x < 0 || std::isnan(x)) {
             x = 0;
         } else if (x > sampleSize[i] - 1) {
             x = sampleSize[i] - 1;
diff --git a/poppler/MarkedContentOutputDev.cc b/poppler/MarkedContentOutputDev.cc
index 9a6f315b..e3a4cdce 100644
--- a/poppler/MarkedContentOutputDev.cc
+++ b/poppler/MarkedContentOutputDev.cc
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2013 Igalia S.L.
-// Copyright 2018-2020 Albert Astals Cid <aacid at kde.org>
+// Copyright 2018-2020, 2022 Albert Astals Cid <aacid at kde.org>
 // Copyright 2021 Adrian Johnson <ajohnson at redneon.com>
 // Copyright 2022 Oliver Sander <oliver.sander at tu-dresden.de>
 //
@@ -17,6 +17,7 @@
 #include "GfxState.h"
 #include "GfxFont.h"
 #include "Annot.h"
+#include <cmath>
 #include <vector>

 MarkedContentOutputDev::MarkedContentOutputDev(int mcidA, const Object &stmObj) : currentFont(nullptr), currentText(nullptr), mcid(mcidA), pageWidth(0.0), pageHeight(0.0), unicodeMap(nullptr)
@@ -181,8 +182,7 @@ void MarkedContentOutputDev::drawChar(GfxState *state, double xx, double yy, dou
         return;
     }

-    // Make a sanity check on character size. Note: (x != x) <-> isnan(x)
-    if (x1 != x1 || y1 != y1 || w1 != w1 || h1 != h1) {
+    if (std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1)) {
         return;
     }

diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 3ed1c90d..06fc3078 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -2666,8 +2666,7 @@ void TextPage::addChar(const GfxState *state, double x, double y, double dx, dou
     // throw away chars that aren't inside the page bounds
     // (and also do a sanity check on the character size)
     state->transform(x, y, &x1, &y1);
-    if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || x1 != x1 || y1 != y1 || // IEEE way of checking for isnan
-        w1 != w1 || h1 != h1) {
+    if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1)) {
         charPos += nBytes;
         return;
     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20220820/d22a6170/attachment-0001.htm>


More information about the poppler mailing list