summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2019-10-02 15:12:17 +0200
committerLars Knoll <lars.knoll@qt.io>2019-10-10 19:45:30 +0200
commit746ab5f16d5c297567341797869b124868a926fe (patch)
tree3cbbec5068464a605f3ddb7fd585cd1b9d5e7ef4 /src/corelib/kernel/qobject.cpp
parent95717ea834a0d9514513809a1b1b179916e6cb35 (diff)
Remove potential out of bounds accesses to QList
Change-Id: I13431e45ef329921a8846c38047f704a299a1a94 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index cf107498dd..fb0d54c801 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2157,7 +2157,9 @@ void QObjectPrivate::setParent_helper(QObject *o)
// cleared our entry in parentD->children.
} else {
const int index = parentD->children.indexOf(q);
- if (parentD->isDeletingChildren) {
+ if (index < 0) {
+ // we're probably recursing into setParent() from a ChildRemoved event, don't do anything
+ } else if (parentD->isDeletingChildren) {
parentD->children[index] = 0;
} else {
parentD->children.removeAt(index);