[postgis-tickets] r15376 - Make copy of string that will be deallocated and remove unused code

bjorn at wololo.org bjorn at wololo.org
Fri Apr 28 09:16:05 PDT 2017


Author: bjornharrtell
Date: 2017-04-28 09:16:04 -0700 (Fri, 28 Apr 2017)
New Revision: 15376

Modified:
   trunk/postgis/geobuf.c
Log:
Make copy of string that will be deallocated and remove unused code

Modified: trunk/postgis/geobuf.c
===================================================================
--- trunk/postgis/geobuf.c	2017-04-28 16:10:21 UTC (rev 15375)
+++ trunk/postgis/geobuf.c	2017-04-28 16:16:04 UTC (rev 15376)
@@ -57,7 +57,9 @@
 	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 @@
 
 	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 @@
 			continue;
 		k++;
 
-		key = tupdesc->attrs[i]->attname.data;
-
 		value = palloc (sizeof (*value));
 		data__value__init(value);
 



More information about the postgis-tickets mailing list