1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +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 61fd218930
commit 7a1d4a2448
5 changed files with 20 additions and 20 deletions

View File

@ -211,7 +211,7 @@ _ltree_extract_isparent(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
item = (ltree *) palloc(VARSIZE(found));
item = (ltree *) palloc0(VARSIZE(found));
memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
@ -234,7 +234,7 @@ _ltree_extract_risparent(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
item = (ltree *) palloc(VARSIZE(found));
item = (ltree *) palloc0(VARSIZE(found));
memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
@ -257,7 +257,7 @@ _ltq_extract_regex(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
item = (ltree *) palloc(VARSIZE(found));
item = (ltree *) palloc0(VARSIZE(found));
memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
@ -280,7 +280,7 @@ _ltxtq_extract_exec(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
item = (ltree *) palloc(VARSIZE(found));
item = (ltree *) palloc0(VARSIZE(found));
memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);