diff options
author | Andres Freund <andres@anarazel.de> | 2016-03-08 14:59:29 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2016-03-08 14:59:29 -0800 |
commit | 814570418d5e6bccb766efbe86d27aef206e5511 (patch) | |
tree | 5d3ddc0bcc82f3eda90d359f140abbd89ef4d47a /contrib/ltree/ltree_gist.c | |
parent | c5f1fbbfb51d852f0e9a1143dae9faa5186c1b2d (diff) | |
download | postgresql-814570418d5e6bccb766efbe86d27aef206e5511.tar.gz postgresql-814570418d5e6bccb766efbe86d27aef206e5511.zip |
ltree: Zero padding bytes when allocating memory for externally visible data.
ltree/ltree_gist/ltxtquery's headers stores data at MAXALIGN alignment,
requiring some padding bytes. So far we left these uninitialized. Zero
those by using palloc0.
Author: Andres Freund
Reported-By: Andres Freund / valgrind / buildarm animal skink
Backpatch: 9.1-
Diffstat (limited to 'contrib/ltree/ltree_gist.c')
-rw-r--r-- | contrib/ltree/ltree_gist.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index 26c34753dcf..bc673d7715e 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -74,7 +74,7 @@ ltree_compress(PG_FUNCTION_ARGS) ltree *val = (ltree *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); int4 len = LTG_HDRSIZE + VARSIZE(val); - key = (ltree_gist *) palloc(len); + key = (ltree_gist *) palloc0(len); SET_VARSIZE(key, len); key->flag = LTG_ONENODE; memcpy((void *) LTG_NODE(key), (void *) val, VARSIZE(val)); @@ -231,7 +231,7 @@ ltree_union(PG_FUNCTION_ARGS) isleqr = (left == right || ISEQ(left, right)) ? true : false; *size = LTG_HDRSIZE + ((isalltrue) ? 0 : SIGLEN) + VARSIZE(left) + ((isleqr) ? 0 : VARSIZE(right)); - result = (ltree_gist *) palloc(*size); + result = (ltree_gist *) palloc0(*size); SET_VARSIZE(result, *size); result->flag = 0; @@ -404,7 +404,7 @@ ltree_picksplit(PG_FUNCTION_ARGS) lu_l = LTG_GETLNODE(GETENTRY(entryvec, array[FirstOffsetNumber].index)); isleqr = (lu_l == lu_r || ISEQ(lu_l, lu_r)) ? true : false; size = LTG_HDRSIZE + ((lisat) ? 0 : SIGLEN) + VARSIZE(lu_l) + ((isleqr) ? 0 : VARSIZE(lu_r)); - lu = (ltree_gist *) palloc(size); + lu = (ltree_gist *) palloc0(size); SET_VARSIZE(lu, size); lu->flag = 0; if (lisat) @@ -421,7 +421,7 @@ ltree_picksplit(PG_FUNCTION_ARGS) ru_l = LTG_GETLNODE(GETENTRY(entryvec, array[1 + ((maxoff - FirstOffsetNumber + 1) / 2)].index)); isleqr = (ru_l == ru_r || ISEQ(ru_l, ru_r)) ? true : false; size = LTG_HDRSIZE + ((risat) ? 0 : SIGLEN) + VARSIZE(ru_l) + ((isleqr) ? 0 : VARSIZE(ru_r)); - ru = (ltree_gist *) palloc(size); + ru = (ltree_gist *) palloc0(size); SET_VARSIZE(ru, size); ru->flag = 0; if (risat) @@ -463,7 +463,7 @@ gist_isparent(ltree_gist *key, ltree *query) static ltree * copy_ltree(ltree *src) { - ltree *dst = (ltree *) palloc(VARSIZE(src)); + ltree *dst = (ltree *) palloc0(VARSIZE(src)); memcpy(dst, src, VARSIZE(src)); return dst; |