From 947392cde907f8a81c8313662051761a6c2ca732 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 31 Aug 2020 22:39:57 +0200 Subject: [PATCH] VariableChooser: Avoid null pointer access The code makes an effort to qobject_cast a pointer and check it, yet it accesses another pointer to do its thing. If the currentWidget is a QPlainTextEdit, this simply crashes. Amends: da3b83589b9 Change-Id: Ie79fa233b04c392fd5aa72cd512fcd0f0d829659 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/variablechooser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 7200d53f609..d9c06e9d6f9 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -469,8 +469,8 @@ void VariableChooserPrivate::updateButtonGeometry() int margin = buttonMargin(); int rightPadding = 0; if (const auto scrollArea = qobject_cast(current)) { - rightPadding = m_textEdit->verticalScrollBar()->isVisible() ? - m_textEdit->verticalScrollBar()->width() : 0; + rightPadding = scrollArea->verticalScrollBar()->isVisible() ? + scrollArea->verticalScrollBar()->width() : 0; } m_iconButton->setGeometry(current->rect().adjusted( current->width() - (margin + 4), 0,