Skip to content
Snippets Groups Projects
Commit 11d9355c authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

collection: Fix potential invalid memory access

Refs #69290
parent bac34590
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ template<typename T> class ItemBase; ...@@ -22,6 +22,7 @@ template<typename T> class ItemBase;
class CollectionInterfacePrivate { class CollectionInterfacePrivate {
public: public:
CollectionInterfacePrivate() : m_pParent(nullptr){}
///The backend parent of nullptr ///The backend parent of nullptr
CollectionInterface* m_pParent ; CollectionInterface* m_pParent ;
......
...@@ -220,7 +220,7 @@ QModelIndex CollectionModel::parent( const QModelIndex& idx ) const ...@@ -220,7 +220,7 @@ QModelIndex CollectionModel::parent( const QModelIndex& idx ) const
QModelIndex CollectionModel::index( int row, int column, const QModelIndex& parent ) const QModelIndex CollectionModel::index( int row, int column, const QModelIndex& parent ) const
{ {
if (parent.isValid()) { if (parent.isValid() && parent.model() == this && row < rowCount(parent)) {
CollectionModelPrivate::ProxyItem* parentItem = static_cast<CollectionModelPrivate::ProxyItem*>(parent.internalPointer()); CollectionModelPrivate::ProxyItem* parentItem = static_cast<CollectionModelPrivate::ProxyItem*>(parent.internalPointer());
CollectionModelPrivate::ProxyItem* item = nullptr; CollectionModelPrivate::ProxyItem* item = nullptr;
if (row < parentItem->m_Children.size()) if (row < parentItem->m_Children.size())
......
...@@ -173,7 +173,7 @@ QString FallbackPersonCollection::name () const ...@@ -173,7 +173,7 @@ QString FallbackPersonCollection::name () const
QString FallbackPersonCollection::category () const QString FallbackPersonCollection::category () const
{ {
return QObject::tr("Contacts"); return QObject::tr("Contact");
} }
QVariant FallbackPersonCollection::icon() const QVariant FallbackPersonCollection::icon() const
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
* index have to be implemented. * index have to be implemented.
*/ */
struct ProxyItem { struct ProxyItem {
ProxyItem() : parent(nullptr),col(1),row(0),collection(nullptr),manageableCount(0){} ProxyItem() : parent(nullptr),col(0),row(0),collection(nullptr),manageableCount(0){}
int row; int row;
int col; int col;
CollectionInterface* collection; CollectionInterface* collection;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment