Skip to content

Commit

Permalink
Fix memory corruption in msGEOSGetCentroid (#6041)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 9, 2020
1 parent 15d9366 commit a5af7f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mapgeos.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ pointObj *msGEOSGetCentroid(shapeObj *shape)
if(!g1) return NULL;

g2 = GEOSGetCentroid_r(handle,g1);
if (!g2) return NULL;

point = (pointObj *) malloc(sizeof(pointObj));

Expand All @@ -952,7 +953,7 @@ pointObj *msGEOSGetCentroid(shapeObj *shape)
GEOSCoordSeq_getY_r(handle,coords, 0, &(point->y));
/* GEOSCoordSeq_getZ(coords, 0, &(point->z)); */

GEOSCoordSeq_destroy_r(handle,coords);
GEOSGeom_destroy_r(handle, g2);

return point;
#else
Expand Down

0 comments on commit a5af7f7

Please sign in to comment.