GBOX gbox;
ND_BOX *nd_box;
bool is_null;
+ bool is_copy;
datum = fetchfunc(stats, i, &is_null);
/* Read the bounds from the gserialized. */
geom = (GSERIALIZED *)PG_DETOAST_DATUM(datum);
+ is_copy = VARATT_IS_EXTENDED(datum);
if ( LW_FAILURE == gserialized_get_gbox_p(geom, &gbox) )
{
/* Skip empties too. */
/* Increment our "good feature" count */
notnull_cnt++;
+
+ /* Free up memory if our sample geometry was copied */
+ if ( is_copy )
+ pfree(geom);
/* Give backend a chance of interrupting us */
vacuum_delay_point();