[partition] Complain loudly on dangling Partition pointers

- Don't crash if a bad pointer gets into colorutils.
This commit is contained in:
Adriaan de Groot 2019-05-31 10:41:50 +02:00
parent 2bc95d11d3
commit 353e713f81

View file

@ -22,6 +22,8 @@
#include "core/KPMHelpers.h"
#include "core/PartitionIterator.h"
#include "utils/Logger.h"
// KPMcore
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/luks.h>
@ -81,6 +83,12 @@ _findRootForPartition( PartitionNode* partition )
QColor
colorForPartition( Partition* partition )
{
if ( !partition )
{
cWarning() << "NULL partition";
return FREE_SPACE_COLOR;
}
if ( KPMHelpers::isPartitionFreeSpace( partition ) )
return FREE_SPACE_COLOR;
if ( partition->roles().has( PartitionRole::Extended ) )