[postgis-tickets] r15797 - Make ST_AsGeoBuf more resiliant when fed rows including NULL geometry (Closes #3861)

Paul Ramsey pramsey at cleverelephant.ca
Fri Sep 22 12:06:58 PDT 2017


Author: pramsey
Date: 2017-09-22 12:06:58 -0700 (Fri, 22 Sep 2017)
New Revision: 15797

Modified:
   trunk/postgis/geobuf.c
Log:
Make ST_AsGeoBuf more resiliant when fed rows including NULL geometry (Closes #3861)


Modified: trunk/postgis/geobuf.c
===================================================================
--- trunk/postgis/geobuf.c	2017-09-22 19:06:11 UTC (rev 15796)
+++ trunk/postgis/geobuf.c	2017-09-22 19:06:58 UTC (rev 15797)
@@ -560,7 +560,7 @@
 void geobuf_agg_transfn(struct geobuf_agg_context *ctx)
 {
 	LWGEOM *lwgeom;
-	bool isnull;
+	bool isnull = false;
 	Datum datum;
 	Data__FeatureCollection *fc = ctx->data->feature_collection;
 	Data__Feature **features = fc->features;
@@ -580,8 +580,9 @@
 		encode_keys(ctx);
 
 	datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
-	if (!datum)
-		elog(ERROR, "geobuf_agg_transfn: geometry column cannot be null");
+	if (isnull)
+		return;
+
 	gs = (GSERIALIZED *) PG_DETOAST_DATUM_COPY(datum);
 	lwgeom = lwgeom_from_gserialized(gs);
 



More information about the postgis-tickets mailing list