Skip to content

Commit

Permalink
don't crash on ofsetting degenerate lines (#4383)
Browse files Browse the repository at this point in the history
closes #4383
  • Loading branch information
tbonfort committed Jul 16, 2012
1 parent d4579e6 commit bca7fd1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions maputil.c
Expand Up @@ -1736,7 +1736,13 @@ shapeObj *msOffsetPolyline(shapeObj *p, double offsetx, double offsety)
}

if(offsety == -99) { /* complex calculations */
int ok = 0;
for (i = 0; i < p->numlines; i++) {
if(p->line[i].numpoints<2) {
ret->line[i].numpoints = 0;
continue; /* skip degenerate lines */
}
ok =1;
pointObj old_pt, old_diffdir, old_offdir;
/* initialize old_offdir and old_diffdir, as gcc isn't smart enough to see that it
* is not an error to do so, and prints a warning */
Expand Down Expand Up @@ -1796,6 +1802,7 @@ shapeObj *msOffsetPolyline(shapeObj *p, double offsetx, double offsety)
ret->line=msSmallRealloc(ret->line,ret->line[i].numpoints*sizeof(pointObj));
}
}
if(!ok) ret->numlines = 0; /* all lines where degenerate */
} else { /* normal offset (eg. drop shadow) */
for (i = 0; i < p->numlines; i++) {
for(j=0; j<p->line[i].numpoints; j++) {
Expand Down

0 comments on commit bca7fd1

Please sign in to comment.