From bf595c4e78187e78d7bedc3e9f95fe5b38683fed Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 30 Sep 2016 11:23:21 +0200 Subject: QFileSystemModel: Plug leak on file renaming In setData(), the old code both called Private::addNode(), which creates a QFileSystemNode and adds it to the parent's QHash of children, and also re-purposed the old node by taking it out of the children hash, adjusting the fileName member of the node and putting it back into the children hash under the new name, where it would overwrite the node just added under the same (new) name in addNode(). Since the hash stores naked pointers, no-one deletes the node that was put into the hash first. Fix by dropping the addNode() call completely. Change-Id: I0c37917fd0ffd74716393786c69b5bb172aa372e Reviewed-by: Edward Welbourne --- src/widgets/dialogs/qfilesystemmodel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a4d4230044..8e4697077e 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -885,7 +885,6 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent; int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName); - d->addNode(parentNode, newName,indexNode->info->fileInfo()); parentNode->visibleChildren.removeAt(visibleLocation); QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName); parentNode->children[newName] = oldValue; -- cgit v1.2.3