From d356876a7375936f04abdf0ed57f75e3f177b102 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 1 Jan 2021 11:27:10 +0100 Subject: [PATCH] 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 (cherry picked from commit f0818f6ed8a616dcc94785637039ac21468ef311) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/widgets/qabstractbutton.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 5ced1397b8b..32fbdccfa4d 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -190,7 +190,9 @@ QListQAbstractButtonPrivate::queryButtonList() const return group->d_func()->buttonList; #endif - QListcandidates = parent->findChildren(); + if (!parent) + return {}; + QList candidates = parent->findChildren(); if (autoExclusive) { auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) { return !candidate->autoExclusive()