summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2021-01-01 11:27:10 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-01 16:55:04 +0000
commitd356876a7375936f04abdf0ed57f75e3f177b102 (patch)
treed7977fe9cbb4231cd54c64c44693a0dcc9fea5db /src/widgets
parentd80faf24d7dcc2292fccf1cb253c239fd6a877ed (diff)
QAbstractButton: don't access nullptr in queryButtonList()
When a button has no parent, QAbstractButtonPrivate::queryButtonList() unconditionally accessed parent which results in a nullptr access. Did not crash because qt_qFindChildren_helper checks for nullptr and therefore could only be found with a sanitizer. Fixes: QTBUG-83865 Change-Id: I591e546e96acba50770935b9c3baaf08b09b833d Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> (cherry picked from commit f0818f6ed8a616dcc94785637039ac21468ef311) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index 5ced1397b8..32fbdccfa4 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -190,7 +190,9 @@ QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const
return group->d_func()->buttonList;
#endif
- QList<QAbstractButton*>candidates = parent->findChildren<QAbstractButton *>();
+ if (!parent)
+ return {};
+ QList<QAbstractButton *> candidates = parent->findChildren<QAbstractButton *>();
if (autoExclusive) {
auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) {
return !candidate->autoExclusive()