Skip to content

Commit

Permalink
Fix for crashes when trying to delete a vertex in a polygon ring that…
Browse files Browse the repository at this point in the history
… has less than 3 vertices (bug 1041)

git-svn-id: http://svn.osgeo.org/qgis/trunk@8358 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 17, 2008
1 parent 16331cf commit ba47247
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/qgsgeometry.cpp
Expand Up @@ -1443,9 +1443,10 @@ bool QgsGeometry::deleteVertexAt(int atVertex)
case QGis::WKBLineString:
{
int* nPoints = (int*)ptr;
if((*nPoints) < 3 || vertexnr > (*nPoints)-1 || vertexnr < 0)
if((*nPoints) < 3 || vertexnr > (*nPoints)-1 || vertexnr < 0) //line needs at least 2 vertices
{
break;
delete newbuffer;
return;
}
int newNPoints = (*nPoints)-1; //new number of points
memcpy(newBufferPtr, &newNPoints, sizeof(int));
Expand Down Expand Up @@ -1498,9 +1499,10 @@ bool QgsGeometry::deleteVertexAt(int atVertex)
//find out if the vertex is in this line
if(vertexnr >= pointindex && vertexnr < pointindex + (*nPoints))
{
if(*nPoints < 3)
if(*nPoints < 3) //line needs at least 2 vertices
{
break;
delete newbuffer;
return false;
}
newNPoint = (*nPoints)-1;
}
Expand Down Expand Up @@ -1557,7 +1559,8 @@ bool QgsGeometry::deleteVertexAt(int atVertex)
{
if(*nPoints < 5) //a ring has at least 3 points
{
break;
delete newbuffer;
return false;
}
newNPoints = *nPoints - 1;
}
Expand Down Expand Up @@ -1634,7 +1637,8 @@ bool QgsGeometry::deleteVertexAt(int atVertex)
{
if(*nPoints < 5) //a ring has at least 3 points
{
break;
delete newbuffer;
return false;
}
newNPoints = *nPoints - 1;
}
Expand Down

0 comments on commit ba47247

Please sign in to comment.