Skip to content

Commit a5af7f7

Browse files
Fix memory corruption in msGEOSGetCentroid (#6041)
1 parent 15d9366 commit a5af7f7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mapgeos.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ pointObj *msGEOSGetCentroid(shapeObj *shape)
943943
if(!g1) return NULL;
944944

945945
g2 = GEOSGetCentroid_r(handle,g1);
946+
if (!g2) return NULL;
946947

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

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

955-
GEOSCoordSeq_destroy_r(handle,coords);
956+
GEOSGeom_destroy_r(handle, g2);
956957

957958
return point;
958959
#else

0 commit comments

Comments
 (0)