From 8a25006fad013f75454d78d976ad02ed7f0f530c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 30 Sep 2016 11:54:54 +0200 Subject: QFileSystemModel: add an assert to prevent leaks Private::addNode() adds the new node to the parent's hash without checking whether a node already exists. If it does, then the old node is leaked. Add an assertion to check for this condition. Change-Id: Ib949d71c86c28d1152a538756c0efc283c793c24 Reviewed-by: Thiago Macieira --- src/widgets/dialogs/qfilesystemmodel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index b27cfa5805..d2b909d201 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1698,6 +1698,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile node->volumeName = QString::fromWCharArray(name); } #endif + Q_ASSERT(!parentNode->children.contains(fileName)); parentNode->children.insert(fileName, node); return node; } -- cgit v1.2.3