#2792 closed defect (fixed)
Crash in get_Area()
Reported by: | fbrachere | Owned by: | Even Rouault |
---|---|---|---|
Priority: | normal | Milestone: | |
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 (6)
comment:1 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I think there is a typo mistake in your commit (you wrote nPoint instead of nPointCount)
comment:3 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
Right, trunk doesn't compile anymore... And I noticed that there was a similar problem with isClockWise()
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 15 years ago
Milestone: | 1.6.1 → 1.5.5 |
---|
Note:
See TracTickets
for help on using tickets.
Correction applied in trunk (r16122), 1.5 branch (r16123) and 1.6 branch (r16124).
Thanks!