summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-03-28 10:43:05 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-03-28 11:16:14 (GMT)
commit45bd1e737f2f76bbc9943995734c6ecb0a23935b (patch)
treeed66dc8c1eff9b8d6dd93ef3b0bc7a3cd888de80 /src
parentcdbb761416996efef99e6eccc7f42730d64f35cb (diff)
downloadQt-45bd1e737f2f76bbc9943995734c6ecb0a23935b.zip
Qt-45bd1e737f2f76bbc9943995734c6ecb0a23935b.tar.gz
Qt-45bd1e737f2f76bbc9943995734c6ecb0a23935b.tar.bz2
Fixed infinite loop in QPainterPath::intersects() when qreal=float.
Similar to c30714122c58a3dc6fd8401427da60c4afc4127b, we need to limit the max number of recursions. Task-number: QTBUG-16422 Reviewed-by: Kim
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpainterpath.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 0948a64..0bb2901 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1863,39 +1863,39 @@ static bool qt_painterpath_isect_line_rect(qreal x1, qreal y1, qreal x2, qreal y
return false;
}
-static bool qt_isect_curve_horizontal(const QBezier &bezier, qreal y, qreal x1, qreal x2)
+static bool qt_isect_curve_horizontal(const QBezier &bezier, qreal y, qreal x1, qreal x2, int depth = 0)
{
QRectF bounds = bezier.bounds();
if (y >= bounds.top() && y < bounds.bottom()
&& bounds.right() >= x1 && bounds.left() < x2) {
const qreal lower_bound = qreal(.01);
- if (bounds.width() < lower_bound && bounds.height() < lower_bound)
+ if (depth == 32 || bounds.width() < lower_bound && bounds.height() < lower_bound)
return true;
QBezier first_half, second_half;
bezier.split(&first_half, &second_half);
- if (qt_isect_curve_horizontal(first_half, y, x1, x2)
- || qt_isect_curve_horizontal(second_half, y, x1, x2))
+ if (qt_isect_curve_horizontal(first_half, y, x1, x2, depth + 1)
+ || qt_isect_curve_horizontal(second_half, y, x1, x2, depth + 1))
return true;
}
return false;
}
-static bool qt_isect_curve_vertical(const QBezier &bezier, qreal x, qreal y1, qreal y2)
+static bool qt_isect_curve_vertical(const QBezier &bezier, qreal x, qreal y1, qreal y2, int depth = 0)
{
QRectF bounds = bezier.bounds();
if (x >= bounds.left() && x < bounds.right()
&& bounds.bottom() >= y1 && bounds.top() < y2) {
const qreal lower_bound = qreal(.01);
- if (bounds.width() < lower_bound && bounds.height() < lower_bound)
+ if (depth == 32 || bounds.width() < lower_bound && bounds.height() < lower_bound)
return true;
QBezier first_half, second_half;
bezier.split(&first_half, &second_half);
- if (qt_isect_curve_vertical(first_half, x, y1, y2)
- || qt_isect_curve_vertical(second_half, x, y1, y2))
+ if (qt_isect_curve_vertical(first_half, x, y1, y2, depth + 1)
+ || qt_isect_curve_vertical(second_half, x, y1, y2, depth + 1))
return true;
}
return false;