Skip to content

Commit af215d8

Browse files
committed
Suppress some more valgrind whining about btree_gist.
A couple of functions didn't bother to zero out pad bytes in datums that would ultimately go to disk. Harmless, but valgrind doesn't know that.
1 parent 39586bc commit af215d8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

contrib/btree_gist/btree_utils_var.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,21 @@ GBT_VARKEY *
7070
gbt_var_key_copy(const GBT_VARKEY_R *u, bool force_node)
7171
{
7272
GBT_VARKEY *r = NULL;
73+
int32 lowersize = VARSIZE(u->lower);
74+
int32 uppersize = VARSIZE(u->upper);
7375

7476
if (u->lower == u->upper && !force_node)
7577
{ /* leaf key mode */
76-
r = (GBT_VARKEY *) palloc(VARSIZE(u->lower) + VARHDRSZ);
77-
memcpy(VARDATA(r), u->lower, VARSIZE(u->lower));
78-
SET_VARSIZE(r, VARSIZE(u->lower) + VARHDRSZ);
78+
r = (GBT_VARKEY *) palloc(lowersize + VARHDRSZ);
79+
memcpy(VARDATA(r), u->lower, lowersize);
80+
SET_VARSIZE(r, lowersize + VARHDRSZ);
7981
}
8082
else
8183
{ /* node key mode */
82-
r = (GBT_VARKEY *) palloc(INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ);
83-
memcpy(VARDATA(r), u->lower, VARSIZE(u->lower));
84-
memcpy(VARDATA(r) + INTALIGN(VARSIZE(u->lower)), u->upper, VARSIZE(u->upper));
85-
SET_VARSIZE(r, INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ);
84+
r = (GBT_VARKEY *) palloc0(INTALIGN(lowersize) + uppersize + VARHDRSZ);
85+
memcpy(VARDATA(r), u->lower, lowersize);
86+
memcpy(VARDATA(r) + INTALIGN(lowersize), u->upper, uppersize);
87+
SET_VARSIZE(r, INTALIGN(lowersize) + uppersize + VARHDRSZ);
8688
}
8789
return r;
8890
}
@@ -201,7 +203,7 @@ gbt_var_node_truncate(const GBT_VARKEY *node, int32 cpf_length, const gbtree_vin
201203
len2 = Min(len2, (cpf_length + 1));
202204

203205
si = 2 * VARHDRSZ + INTALIGN(len1 + VARHDRSZ) + len2;
204-
out = (GBT_VARKEY *) palloc(si);
206+
out = (GBT_VARKEY *) palloc0(si);
205207
SET_VARSIZE(out, si);
206208

207209
memcpy(VARDATA(out), r.lower, len1 + VARHDRSZ);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy