Permalink
Browse files

Fix A layer using a mask and a label with repeatdistance can crash (#…

  • Loading branch information...
Alan Boudreault
Alan Boudreault committed Sep 25, 2013
1 parent c4a70d7 commit f82d6c8946c91dbeeb38a8a7d5b0aa674f8002b3
Showing with 49 additions and 40 deletions.
  1. +49 −40 maplabel.c
View
@@ -351,25 +351,28 @@ int msAddLabelGroup(mapObj *map, int layerindex, int classindex, shapeObj *shape
MS_IMAGE_RENDERER(maskLayer->maskimage)->getRasterBufferHandle(maskLayer->maskimage,&rb);
x = MS_NINT(point->x);
y = MS_NINT(point->y);
/* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */
if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) {
#ifdef USE_GD
if(rb.type == MS_BUFFER_BYTE_RGBA) {
if(rb.type == MS_BUFFER_BYTE_RGBA) {
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
} else {
if(!gdImageGetPixel(rb.data.gd_img,x,y))
return MS_SUCCESS;
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
} else {
if(!gdImageGetPixel(rb.data.gd_img,x,y))
return MS_SUCCESS;
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
#endif
}
} else {
msSetError(MS_MISCERR, "Layer (%s) references references a mask layer, but the selected renderer does not support them", "msAddLabelGroup()", layerPtr->name);
return (MS_FAILURE);
@@ -543,54 +546,60 @@ int msAddLabel(mapObj *map, labelObj *label, int layerindex, int classindex, sha
if (point) {
int x = MS_NINT(point->x);
int y = MS_NINT(point->y);
/* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */
if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) {
#ifdef USE_GD
if(rb.type == MS_BUFFER_BYTE_RGBA) {
if(rb.type == MS_BUFFER_BYTE_RGBA) {
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
} else {
if(!gdImageGetPixel(rb.data.gd_img,x,y)) {
return MS_SUCCESS;
}
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
} else {
if(!gdImageGetPixel(rb.data.gd_img,x,y)) {
return MS_SUCCESS;
}
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x;
if(!*alphapixptr) {
/* label point does not intersect mask */
return MS_SUCCESS;
}
#endif
}
} else if (labelpath) {
int i = 0;
for (i = 0; i < labelpath->path.numpoints; i++) {
int x = MS_NINT(labelpath->path.point[i].x);
int y = MS_NINT(labelpath->path.point[i].y);
/* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */
if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) {
#ifdef USE_GD
if (rb.type == MS_BUFFER_BYTE_RGBA) {
if (rb.type == MS_BUFFER_BYTE_RGBA) {
alphapixptr = rb.data.rgba.a + rb.data.rgba.row_step * y + rb.data.rgba.pixel_step*x;
if (!*alphapixptr) {
/* label point does not intersect mask */
msFreeLabelPathObj(labelpath);
return MS_SUCCESS;
}
} else {
if (!gdImageGetPixel(rb.data.gd_img, x, y)) {
msFreeLabelPathObj(labelpath);
return MS_SUCCESS;
}
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a + rb.data.rgba.row_step * y + rb.data.rgba.pixel_step*x;
if (!*alphapixptr) {
/* label point does not intersect mask */
msFreeLabelPathObj(labelpath);
return MS_SUCCESS;
}
} else {
if (!gdImageGetPixel(rb.data.gd_img, x, y)) {
msFreeLabelPathObj(labelpath);
return MS_SUCCESS;
}
}
#else
assert(rb.type == MS_BUFFER_BYTE_RGBA);
alphapixptr = rb.data.rgba.a + rb.data.rgba.row_step * y + rb.data.rgba.pixel_step*x;
if (!*alphapixptr) {
/* label point does not intersect mask */
msFreeLabelPathObj(labelpath);
return MS_SUCCESS;
}
#endif
}
}
}
} else {

0 comments on commit f82d6c8

Please sign in to comment.