summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2021-01-04 18:05:44 +0100
committerAlbert Astals Cid <aacid@kde.org>2021-01-04 18:05:44 +0100
commite126be08ea94d829a2d25aabb2ef79cc7bf65d4c (patch)
tree0e6ecdc813a106b54e02db904847b9460a641003
parent43126be585e587f6f571a0170f0f63098b82d064 (diff)
SplashXPathScanner: If any of the segments of the path is nan, path is not valid
Fixes crash in broken files #1022
-rw-r--r--splash/SplashXPathScanner.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/splash/SplashXPathScanner.cc b/splash/SplashXPathScanner.cc
index 62904121..98a49912 100644
--- a/splash/SplashXPathScanner.cc
+++ b/splash/SplashXPathScanner.cc
@@ -11,7 +11,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2008, 2010, 2014, 2018, 2019 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008, 2010, 2014, 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha@gmail.com>
// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2018 Stefan Brüns <stefan.bruens@rwth-aachen.de>
@@ -49,11 +49,13 @@ SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, bool eoA, int clipYM
partialClip = false;
// compute the bbox
- if (xPath->length == 0) {
- xMin = yMin = 1;
- xMax = yMax = 0;
- } else {
+ xMin = yMin = 1;
+ xMax = yMax = 0;
+ if (xPath->length > 0) {
seg = &xPath->segs[0];
+ if (unlikely(std::isnan(seg->x0) || std::isnan(seg->x1) || std::isnan(seg->y0) || std::isnan(seg->y1))) {
+ return;
+ }
if (seg->x0 <= seg->x1) {
xMinFP = seg->x0;
xMaxFP = seg->x1;
@@ -70,6 +72,9 @@ SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, bool eoA, int clipYM
}
for (i = 1; i < xPath->length; ++i) {
seg = &xPath->segs[i];
+ if (unlikely(std::isnan(seg->x0) || std::isnan(seg->x1) || std::isnan(seg->y0) || std::isnan(seg->y1))) {
+ return;
+ }
if (seg->x0 < xMinFP) {
xMinFP = seg->x0;
} else if (seg->x0 > xMaxFP) {