Skip to content

Commit 7b60468

Browse files
committed
Fix variable initialization when using buffering build with GiST
This can cause valgrind to complain, as the flag marking a buffer as a temporary copy was not getting initialized. While on it, fill in with zeros newly-created buffer pages. This does not matter when loading a block from a temporary file, but it makes the push of an index tuple into a new buffer page safer. This has been introduced by 1d27dcf, so backpatch all the way down to 9.4. Author: Alexander Lakhin Discussion: https://postgr.es/m/15899-0d24fb273b3dd90c@postgresql.org Backpatch-through: 9.4
1 parent d49c127 commit 7b60468

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/access/gist/gistbuildbuffers.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
140140
nodeBuffer->pageBlocknum = InvalidBlockNumber;
141141
nodeBuffer->pageBuffer = NULL;
142142
nodeBuffer->queuedForEmptying = false;
143+
nodeBuffer->isTemp = false;
143144
nodeBuffer->level = level;
144145

145146
/*
@@ -188,8 +189,8 @@ gistAllocateNewPageBuffer(GISTBuildBuffers *gfbb)
188189
{
189190
GISTNodeBufferPage *pageBuffer;
190191

191-
pageBuffer = (GISTNodeBufferPage *) MemoryContextAlloc(gfbb->context,
192-
BLCKSZ);
192+
pageBuffer = (GISTNodeBufferPage *) MemoryContextAllocZero(gfbb->context,
193+
BLCKSZ);
193194
pageBuffer->prev = InvalidBlockNumber;
194195

195196
/* Set page free space */

0 commit comments

Comments
 (0)