]> granicus.if.org Git - postgis/commitdiff
Make copy of string that will be deallocated and remove unused code
authorBjörn Harrtell <bjorn@wololo.org>
Fri, 28 Apr 2017 16:16:04 +0000 (16:16 +0000)
committerBjörn Harrtell <bjorn@wololo.org>
Fri, 28 Apr 2017 16:16:04 +0000 (16:16 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@15376 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geobuf.c

index 5970936e4853543d8e00ab6a81a6614c592c599f..ddecf5975901b58660627038a48c844701bab281 100644 (file)
@@ -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);