1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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-
This commit is contained in:
Andres Freund
2016-03-08 14:59:29 -08:00
parent 44f9f1f2d5
commit 12449f1409
5 changed files with 20 additions and 20 deletions

View File

@ -230,7 +230,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos)
ptr = LEVEL_NEXT(ptr);
}
res = (ltree *) palloc(LTREE_HDRSIZE + (end - start));
res = (ltree *) palloc0(LTREE_HDRSIZE + (end - start));
SET_VARSIZE(res, LTREE_HDRSIZE + (end - start));
res->numlevel = endpos - startpos;
@ -287,7 +287,7 @@ ltree_concat(ltree *a, ltree *b)
{
ltree *r;
r = (ltree *) palloc(VARSIZE(a) + VARSIZE(b) - LTREE_HDRSIZE);
r = (ltree *) palloc0(VARSIZE(a) + VARSIZE(b) - LTREE_HDRSIZE);
SET_VARSIZE(r, VARSIZE(a) + VARSIZE(b) - LTREE_HDRSIZE);
r->numlevel = a->numlevel + b->numlevel;
@ -469,7 +469,7 @@ lca_inner(ltree **a, int len)
l1 = LEVEL_NEXT(l1);
}
res = (ltree *) palloc(reslen);
res = (ltree *) palloc0(reslen);
SET_VARSIZE(res, reslen);
res->numlevel = num;