PartitionModule: avoid nullptr crashes
Fix up iterator code so that it handles nullptr better. This avoids part of #686.
This commit is contained in:
parent
2dbcee346d
commit
8823938c8f
@ -157,9 +157,9 @@ PartitionCoreModule::doInit()
|
|||||||
|
|
||||||
// Remove the device which contains / from the list
|
// Remove the device which contains / from the list
|
||||||
for ( QList< Device* >::iterator it = devices.begin(); it != devices.end(); )
|
for ( QList< Device* >::iterator it = devices.begin(); it != devices.end(); )
|
||||||
if ( hasRootPartition( *it ) ||
|
if ( *it && ( hasRootPartition( *it ) ||
|
||||||
(*it)->deviceNode().startsWith( "/dev/zram") ||
|
(*it)->deviceNode().startsWith( "/dev/zram") ||
|
||||||
isIso9660( *it ) )
|
isIso9660( *it ) ) )
|
||||||
it = devices.erase( it );
|
it = devices.erase( it );
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -83,6 +84,8 @@ PartitionIterator::operator!=( const PartitionIterator& other ) const
|
|||||||
PartitionIterator
|
PartitionIterator
|
||||||
PartitionIterator::begin( Device* device )
|
PartitionIterator::begin( Device* device )
|
||||||
{
|
{
|
||||||
|
if ( !device )
|
||||||
|
return PartitionIterator( nullptr );
|
||||||
Q_ASSERT(device);
|
Q_ASSERT(device);
|
||||||
PartitionTable* table = device->partitionTable();
|
PartitionTable* table = device->partitionTable();
|
||||||
if ( !table )
|
if ( !table )
|
||||||
@ -106,6 +109,8 @@ PartitionIterator::begin( PartitionTable* table )
|
|||||||
PartitionIterator
|
PartitionIterator
|
||||||
PartitionIterator::end( Device* device )
|
PartitionIterator::end( Device* device )
|
||||||
{
|
{
|
||||||
|
if ( !device )
|
||||||
|
return PartitionIterator( nullptr );
|
||||||
PartitionTable* table = device->partitionTable();
|
PartitionTable* table = device->partitionTable();
|
||||||
if ( !table )
|
if ( !table )
|
||||||
return PartitionIterator( nullptr );
|
return PartitionIterator( nullptr );
|
||||||
|
Loading…
Reference in New Issue
Block a user