From eede5747237ac736340b01ad5b913f479011ddff Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Sun, 8 Jan 2023 15:07:16 +0100 Subject: [PATCH] Fix potential nullptr de-reference The `break` that is replaced by a `return` here would only break out of the innermost while loop so the std::vector::end could still become accessed after that. By returning here we completely exit out of both nested loops and therefore don't access the std::vector::end. --- src/selectionmode/backgroundcolorhelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selectionmode/backgroundcolorhelper.cpp b/src/selectionmode/backgroundcolorhelper.cpp index 893a75ccf..799db43d5 100644 --- a/src/selectionmode/backgroundcolorhelper.cpp +++ b/src/selectionmode/backgroundcolorhelper.cpp @@ -56,7 +56,7 @@ void BackgroundColorHelper::slotPaletteChanged() while (!*i) { i = m_colorControlledWidgets.erase(i); if (i == m_colorControlledWidgets.end()) { - break; + return; } } setBackgroundColorForWidget(*i, m_backgroundColor);