mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-09 00:35:20 -05:00
Fix a crash when running 'snap geometries to layer'
A crash may happen when running the alg with 'snap to anchor nodes (single layer only)' behavior. It turns out that I made a mistake while porting the algorithm to std::sort - originally the sorting function used -1/0/+1 for comparison, while std::sort wants '<' operator returning true/false. Due to inconsistent results from the comparison function, std::sort would end up corrupting the array and memory even beyond the range, causing crashes. Related to #29400 (but does not fix it)
This commit is contained in:
parent
2a9028ad28
commit
0ba99af486
@ -244,9 +244,9 @@ static bool snapLineString( QgsLineString *linestring, QgsSpatialIndex &index, Q
|
||||
if ( !newVerticesAlongSegment.isEmpty() )
|
||||
{
|
||||
// sort by distance along the segment
|
||||
std::sort( newVerticesAlongSegment.begin(), newVerticesAlongSegment.end(), []( AnchorAlongSegment p1, AnchorAlongSegment p2 )
|
||||
std::sort( newVerticesAlongSegment.begin(), newVerticesAlongSegment.end(), []( const AnchorAlongSegment & p1, const AnchorAlongSegment & p2 )
|
||||
{
|
||||
return ( p1.along < p2.along ? -1 : ( p1.along > p2.along ) );
|
||||
return p1.along < p2.along;
|
||||
} );
|
||||
|
||||
// insert new vertices
|
||||
|
Loading…
x
Reference in New Issue
Block a user