[postgis-tickets] r16508 - Avoid incompatible automatic variable length array
Sandro Santilli
strk at kbt.io
Wed Mar 28 08:01:18 PDT 2018
Author: strk
Date: 2018-03-28 08:01:18 -0700 (Wed, 28 Mar 2018)
New Revision: 16508
Modified:
trunk/postgis/geography_centroid.c
Log:
Avoid incompatible automatic variable length array
Patch by vmo
Closes #4059
Modified: trunk/postgis/geography_centroid.c
===================================================================
--- trunk/postgis/geography_centroid.c 2018-03-28 15:01:12 UTC (rev 16507)
+++ trunk/postgis/geography_centroid.c 2018-03-28 15:01:18 UTC (rev 16508)
@@ -105,7 +105,7 @@
/* average between all points */
uint32_t size = mpoints->ngeoms;
- POINT3DM points[size];
+ POINT3DM* points = palloc(size*sizeof(POINT3DM));
uint32_t i;
for (i = 0; i < size; i++) {
@@ -115,6 +115,7 @@
}
lwpoint_out = geography_centroid_from_wpoints(srid, points, size);
+ pfree(points);
break;
}
@@ -258,7 +259,7 @@
size += (mline->geoms[i]->points->npoints - 1) * 2;
}
- POINT3DM points[size];
+ POINT3DM* points = palloc(size*sizeof(POINT3DM));
uint32_t j = 0;
for (i = 0; i < mline->ngeoms; i++) {
@@ -295,7 +296,9 @@
}
}
- return geography_centroid_from_wpoints(mline->srid, points, size);
+ LWPOINT* result = geography_centroid_from_wpoints(mline->srid, points, size);
+ pfree(points);
+ return result;
}
@@ -313,7 +316,7 @@
}
}
- POINT3DM points[size];
+ POINT3DM* points = palloc(size*sizeof(POINT3DM));
uint32_t j = 0;
/* use first point as reference to create triangles */
@@ -379,6 +382,7 @@
}
}
}
-
- return geography_centroid_from_wpoints(mpoly->srid, points, size);
+ LWPOINT* result = geography_centroid_from_wpoints(mpoly->srid, points, size);
+ pfree(points);
+ return result;
}
More information about the postgis-tickets
mailing list