From e0a79f4c0f4231355a705efcd676bb26a5fbc2df Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 3 May 2019 08:47:34 -0400 Subject: [PATCH] [partition] Reduce scope for nullptr dereference - document what types are in use - avoid at least one nullptr deref --- src/modules/partition/core/PartitionCoreModule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 183fdfcac..b230a23fb 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -946,9 +946,12 @@ PartitionCoreModule::revertDevice( Device* dev, bool individualRevert ) m_deviceModel->swapDevice( dev, newDev ); QList< Device* > devices; - for ( auto info : m_deviceInfos ) + for ( DeviceInfo* const info : m_deviceInfos ) { - if ( info->device.data()->type() != Device::Type::Disk_Device ) + // device is a QScopedPointer + if ( !info || info->device.isNull() ) + continue; + if ( info->device->type() != Device::Type::Disk_Device ) continue; else devices.append( info->device.data() );