From: Björn Harrtell Date: Fri, 28 Apr 2017 16:16:04 +0000 (+0000) Subject: Make copy of string that will be deallocated and remove unused code X-Git-Tag: 2.4.0alpha~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=502061f0db9013be12c5d88cca70e60ea4798003;p=postgis Make copy of string that will be deallocated and remove unused code git-svn-id: http://svn.osgeo.org/postgis/trunk@15376 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geobuf.c b/postgis/geobuf.c index 5970936e4..ddecf5975 100644 --- a/postgis/geobuf.c +++ b/postgis/geobuf.c @@ -57,7 +57,9 @@ static void encode_keys(struct geobuf_agg_context *ctx) uint32_t i, k = 0; bool geom_name_found = false; for (i = 0; i < natts; i++) { - char *key = tupdesc->attrs[i]->attname.data; + char *tkey = tupdesc->attrs[i]->attname.data; + char *key = palloc(sizeof(*tkey)); + strcpy(key, tkey); if (strcmp(key, ctx->geom_name) == 0) { ctx->geom_index = i; geom_name_found = true; @@ -96,7 +98,7 @@ static void encode_properties(struct geobuf_agg_context *ctx, for (i = 0; i < natts; i++) { Data__Value *value; - char *type, *string_value, *key; + char *type, *string_value; Datum datum; bool isnull; @@ -104,8 +106,6 @@ static void encode_properties(struct geobuf_agg_context *ctx, continue; k++; - key = tupdesc->attrs[i]->attname.data; - value = palloc (sizeof (*value)); data__value__init(value);