From: Björn Harrtell Date: Fri, 28 Apr 2017 17:27:48 +0000 (+0000) Subject: Fix wrong char * allocation size X-Git-Tag: 2.4.0alpha~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20118e7d06a84ad419b7168a7facb938c58b6302;p=postgis Fix wrong char * allocation size git-svn-id: http://svn.osgeo.org/postgis/trunk@15377 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geobuf.c b/postgis/geobuf.c index ddecf5975..6c5ca1f7c 100644 --- a/postgis/geobuf.c +++ b/postgis/geobuf.c @@ -58,7 +58,7 @@ static void encode_keys(struct geobuf_agg_context *ctx) bool geom_name_found = false; for (i = 0; i < natts; i++) { char *tkey = tupdesc->attrs[i]->attname.data; - char *key = palloc(sizeof(*tkey)); + char *key = palloc(strlen(tkey) + 1); strcpy(key, tkey); if (strcmp(key, ctx->geom_name) == 0) { ctx->geom_index = i; diff --git a/postgis/mvt.c b/postgis/mvt.c index b4da299f4..a2e039ff6 100644 --- a/postgis/mvt.c +++ b/postgis/mvt.c @@ -275,7 +275,7 @@ static void encode_keys(struct mvt_agg_context *ctx) bool geom_name_found = false; for (i = 0; i < natts; i++) { char *tkey = tupdesc->attrs[i]->attname.data; - char *key = palloc(sizeof(*tkey)); + char *key = palloc(strlen(tkey) + 1); strcpy(key, tkey); if (strcmp(key, ctx->geom_name) == 0) { ctx->geom_index = i;