Ticket #2792 (closed defect: fixed)
Crash in get_Area()
| Reported by: | fbrachere | Owned by: | rouault |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.5.5 |
| Component: | OGR_SF | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Gdal crash in OGRLinearRing::get_Area() if the linearRing contains zero point, a sample code:
int main (int argc, char **argv)
{
OGRPolygon *poly = new OGRPolygon();
OGRLinearRing *extRing = new OGRLinearRing();
poly->addRing(extRing);
double area = poly->get_Area();
printf("Area: %f\n",area);
return 0;
}
The problem is in the file ogrlinearring.cpp, line 431 (for gdal 1.6.0):
dfAreaSum += 0.5 * ( paoPoints[nPointCount-1].x * paoPoints[0].y
- paoPoints[0].x * paoPoints[nPointCount-1].y );
We can patch like this:
if (nPointCount)
dfAreaSum += 0.5 * ( paoPoints[nPointCount-1].x * paoPoints[0].y
- paoPoints[0].x * paoPoints[nPointCount-1].y );
Change History
Note: See
TracTickets for help on using
tickets.
