[postgis-tickets] r17405 - Call POSTGIS2GEOS in aggregate context.

Darafei komzpa at gmail.com
Sun Apr 21 08:52:00 PDT 2019


Author: komzpa
Date: 2019-04-21 08:52:00 -0700 (Sun, 21 Apr 2019)
New Revision: 17405

Modified:
   trunk/postgis/lwgeom_geos.c
Log:
Call POSTGIS2GEOS in aggregate context.

References #4382


Modified: trunk/postgis/lwgeom_geos.c
===================================================================
--- trunk/postgis/lwgeom_geos.c	2019-04-21 13:41:50 UTC (rev 17404)
+++ trunk/postgis/lwgeom_geos.c	2019-04-21 15:52:00 UTC (rev 17405)
@@ -572,6 +572,7 @@
 
 		if (!gserialized_is_empty(gser_in))
 		{
+			MemoryContext old = MemoryContextSwitchTo(aggcontext);
 			if (state->ngeoms == 0)
 			{
 				state->srid = gserialized_get_srid(gser_in);
@@ -592,13 +593,12 @@
 
 			if (state->ngeoms > state->alen)
 			{
-				MemoryContext old = MemoryContextSwitchTo(aggcontext);
 				state->alen *= 2;
 				state->geoms = repalloc(state->geoms, state->alen);
-				MemoryContextSwitchTo(old);
 			}
 
 			state->geoms[curgeom] = g;
+			MemoryContextSwitchTo(old);
 		}
 		else
 		{



More information about the postgis-tickets mailing list