Permalink
Browse files

fix segfault when computing degenerate line lengths (#4972)

  • Loading branch information...
tbonfort committed Aug 19, 2014
1 parent 132a16e commit e5c2e65dc01f030790dea394f81c814e2d468cb4
Showing with 5 additions and 1 deletion.
  1. +5 −1 mapprimitive.c
View
@@ -1547,7 +1547,11 @@ void msPolylineComputeLineSegments(shapeObj *shape, struct polyline_lengths *pll
struct line_lengths *ll = &pll->ll[i];
double max_subline_segment_length = 0;
- ll->segment_lengths = (double*) msSmallMalloc(sizeof(double) * (shape->line[i].numpoints - 1));
+ if(shape->line[i].numpoints > 1) {
+ ll->segment_lengths = (double*) msSmallMalloc(sizeof(double) * (shape->line[i].numpoints - 1));
+ } else {
+ ll->segment_lengths = NULL;
+ }
ll->total_length = 0;
for(j=1; j<shape->line[i].numpoints; j++) {

0 comments on commit e5c2e65

Please sign in to comment.