<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Should tests for != splashOk be wrapped in unlikely()?<br>
</div>
<div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> poppler <poppler-bounces@lists.freedesktop.org> on behalf of GitLab Mirror <gitlab-mirror@kemper.freedesktop.org><br>
<b>Sent:</b> Saturday, September 5, 2020 3:41 PM<br>
<b>To:</b> poppler@lists.freedesktop.org <poppler@lists.freedesktop.org><br>
<b>Subject:</b> [poppler] splash/Splash.cc splash/SplashPath.cc</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">splash/Splash.cc | 4 +++-<br>
splash/SplashPath.cc | 10 ++++++++--<br>
2 files changed, 11 insertions(+), 3 deletions(-)<br>
<br>
New commits:<br>
commit c47713528f770ac89c90d662aae72c7e48c9497b<br>
Author: Albert Astals Cid <aacid@kde.org><br>
Date: Sat Sep 5 21:26:37 2020 +0200<br>
<br>
addStrokeAdjustHint(): fix crash in out-of-memory situation.<br>
<br>
Fixes <a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25411">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25411</a><br>
<br>
#0 0xf7ef8f19 in [vdso]<br>
#1 0xf7ccdd08 in gsignal (/lib32/libc.so.6+0x2bd08)<br>
#2 0xf7ccf206 in abort (/lib32/libc.so.6+0x2d206)<br>
#3 0xbdb9c2e in grealloc(void*, unsigned int, bool) gdal/poppler/goo/gmem.h:85:5<br>
#4 0xbdd9e11 in greallocn(void*, int, int, bool, bool) gdal/poppler/goo/gmem.h:171:12<br>
#5 0xc012373 in SplashPath::addStrokeAdjustHint(int, int, int, int) gdal/poppler/splash/SplashPath.cc:211:35<br>
#6 0xbfd156f in Splash::makeStrokePath(SplashPath*, double, bool) gdal/poppler/splash/Splash.cc:5987:34<br>
#7 0xbfcaec2 in Splash::strokeWide(SplashPath*, double) gdal/poppler/splash/Splash.cc:2028:13<br>
#8 0xbfc8a4d in Splash::stroke(SplashPath*) /src/gdal/poppler/splash/Splash.cc<br>
<br>
Based on patch by Even Rouault<br>
<br>
diff --git a/splash/Splash.cc b/splash/Splash.cc<br>
index a020c749..584e65c7 100644<br>
--- a/splash/Splash.cc<br>
+++ b/splash/Splash.cc<br>
@@ -5844,7 +5844,9 @@ SplashPath *Splash::makeStrokePath(SplashPath *path, SplashCoord w, bool flatten<br>
wdy = (SplashCoord)0.5 * w * dy;<br>
<br>
// draw the start cap<br>
- pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx);<br>
+ if (pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx) != splashOk) {<br>
+ break;<br>
+ }<br>
if (i0 == subpathStart0) {<br>
firstPt = pathOut->length - 1;<br>
}<br>
diff --git a/splash/SplashPath.cc b/splash/SplashPath.cc<br>
index 33216cfb..7c7e8523 100644<br>
--- a/splash/SplashPath.cc<br>
+++ b/splash/SplashPath.cc<br>
@@ -196,7 +196,10 @@ SplashError SplashPath::close(bool force)<br>
return splashErrNoCurPt;<br>
}<br>
if (force || curSubpath == length - 1 || pts[length - 1].x != pts[curSubpath].x || pts[length - 1].y != pts[curSubpath].y) {<br>
- lineTo(pts[curSubpath].x, pts[curSubpath].y);<br>
+ const auto lineToStatus = lineTo(pts[curSubpath].x, pts[curSubpath].y);<br>
+ if (lineToStatus != splashOk) {<br>
+ return lineToStatus;<br>
+ }<br>
}<br>
flags[curSubpath] |= splashPathClosed;<br>
flags[length - 1] |= splashPathClosed;<br>
@@ -208,7 +211,10 @@ void SplashPath::addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int last<br>
{<br>
if (hintsLength == hintsSize) {<br>
hintsSize = hintsLength ? 2 * hintsLength : 8;<br>
- hints = (SplashPathHint *)greallocn(hints, hintsSize, sizeof(SplashPathHint));<br>
+ hints = (SplashPathHint *)greallocn_checkoverflow(hints, hintsSize, sizeof(SplashPathHint));<br>
+ }<br>
+ if (unlikely(!hints)) {<br>
+ return;<br>
}<br>
hints[hintsLength].ctrl0 = ctrl0;<br>
hints[hintsLength].ctrl1 = ctrl1;<br>
_______________________________________________<br>
poppler mailing list<br>
poppler@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/poppler">https://lists.freedesktop.org/mailman/listinfo/poppler</a><br>
</div>
</span></font></div>
</div>
</body>
</html>