summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-04-26 10:36:04 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-29 08:09:24 +0200
commita298216bb4383dbe96688dfb80da0cd875766de0 (patch)
tree9560e63f2d32e875ee234a3424ef17b865634ebf /src/widgets/kernel/qwidget.cpp
parent3d42f6fed220cd0cd24924eb55db4b2751eed74c (diff)
Prevent crash due to giving QWidget::update() a large rect.
We can simply clip the update rect against the widget's rect and return if it's empty. Otherwise we risk ending up with update rects that are larger than INT_MAX due to multiple update rects being merged. Task-number: QTBUG-30876 Change-Id: I23bd0149fbe8d1a007a60b228e6bddb45dc4fc32 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 3b796fe35b..cb7761add7 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -9874,11 +9874,16 @@ void QWidget::update()
*/
void QWidget::update(const QRect &rect)
{
- if (!isVisible() || !updatesEnabled() || rect.isEmpty())
+ if (!isVisible() || !updatesEnabled())
+ return;
+
+ QRect r = rect & QWidget::rect();
+
+ if (r.isEmpty())
return;
if (testAttribute(Qt::WA_WState_InPaintEvent)) {
- QApplication::postEvent(this, new QUpdateLaterEvent(rect));
+ QApplication::postEvent(this, new QUpdateLaterEvent(r));
return;
}
@@ -9891,9 +9896,9 @@ void QWidget::update(const QRect &rect)
#endif // Q_WS_MAC
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
- tlwExtra->backingStoreTracker->markDirty(rect, this);
+ tlwExtra->backingStoreTracker->markDirty(r, this);
} else {
- d_func()->repaint_sys(rect);
+ d_func()->repaint_sys(r);
}
}