Skip to content

Commit 1be40f5

Browse files
committedJan 20, 2019
Add a nullptr guard in the geometry equality check
1 parent 2c00790 commit 1be40f5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
 

‎src/core/geometry/qgsgeometrycollection.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,19 @@ bool QgsGeometryCollection::operator==( const QgsAbstractGeometry &other ) const
7878

7979
for ( int i = 0; i < mGeometries.count(); ++i )
8080
{
81-
if ( mGeometries.at( i ) != otherCollection->mGeometries.at( i )
82-
&& mGeometries.at( i )->operator!=( *otherCollection->mGeometries.at( i ) ) )
83-
return false;
81+
QgsAbstractGeometry *g1 = mGeometries.at( i );
82+
QgsAbstractGeometry *g2 = otherCollection->mGeometries.at( i );
83+
84+
// Quick check if the geometries are exactly the same
85+
if ( g1 != g2 )
86+
{
87+
if ( !g1 || !g2 )
88+
return false;
89+
90+
// Slower check, compare the contents of the geometries
91+
if ( *g1 != *g2 )
92+
return false;
93+
}
8494
}
8595

8696
return true;

0 commit comments

Comments
 (0)
Please sign in to comment.