From 8b9c6ba4b3afbc8188b4a0e689a5302f01da30d1 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 5 Dec 2016 15:47:55 +0100 Subject: [PATCH] Core: Prevent possible nullptr access I doubt that this can happen in practice, but better be save than sorry:-) Change-Id: I30919e9ba16c2cc8cf401fc0c9f49267a215af71 Reviewed-by: Tim Jenssen Reviewed-by: Eike Ziller --- src/plugins/coreplugin/find/highlightscrollbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/find/highlightscrollbar.cpp b/src/plugins/coreplugin/find/highlightscrollbar.cpp index c9e8a98eb0a..c7cc690fa93 100644 --- a/src/plugins/coreplugin/find/highlightscrollbar.cpp +++ b/src/plugins/coreplugin/find/highlightscrollbar.cpp @@ -25,6 +25,8 @@ #include "highlightscrollbar.h" +#include + #include #include #include @@ -252,7 +254,7 @@ void HighlightScrollBarOverlay::paintEvent(QPaintEvent *paintEvent) int top = rect.top() + offset + verticalMargin + float(it.key()) / range * rect.height(); const int bottom = top + resultHeight; - if (previousCategory == currentCategory && previousBottom + 1 >= top) { + if (QTC_GUARD(previousRect) && previousCategory == currentCategory && previousBottom + 1 >= top) { // If the previous highlight has the same category and is directly prior to this highlight // we just extend the previous highlight. previousRect->setBottom(bottom - 1);