Skip to content

Commit 1605f9e

Browse files
author
Maxim Orlov
committed
Fix valgrind errors when work_mem < 1 MB
- fix write uninited values in logical tape - fix double free
1 parent f608c36 commit 1605f9e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/rumget.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ scanPostingTree(Relation index, RumScanEntry scanEntry,
252252
RumScanItem item;
253253
Pointer ptr;
254254

255+
MemSet(&item, 0, sizeof(item));
255256
ItemPointerSetMin(&item.item.iptr);
256257

257258
ptr = RumDataPageGetData(page);

src/rumsort.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ copytup_rumitem(RumTuplesortstate * state, SortTuple *stup, void *tup)
202202
#define LogicalTapeReadExact_compat(state, LT_ARG, args...) LogicalTapeReadExact(state->tapeset, LT_ARG, ##args)
203203
#endif
204204

205-
static size_t rum_item_size(RumTuplesortstate * state)
205+
static Size
206+
rum_item_size(RumTuplesortstate * state)
206207
{
207208
if (state->copytup == copytup_rum)
208209
return RumSortItemSize(state->nKeys);
@@ -226,9 +227,6 @@ writetup_rum_internal(RumTuplesortstate * state, LT_TYPE LT_ARG, SortTuple *stup
226227
if (state->randomAccess) /* need trailing length word? */
227228
LogicalTapeWrite(TAPE(state, LT_ARG),
228229
(void *) &writtenlen, sizeof(writtenlen));
229-
230-
FREEMEM(state, GetMemoryChunkSpace(item));
231-
pfree(item);
232230
}
233231

234232
static void
@@ -251,7 +249,7 @@ readtup_rum_internal(RumTuplesortstate * state, SortTuple *stup,
251249
size_t size = rum_item_size(state);
252250
void *item = palloc(size);
253251

254-
Assert(tuplen == RumSortItemSize(state->nKeys));
252+
Assert(tuplen == size);
255253

256254
USEMEM(state, GetMemoryChunkSpace(item));
257255
LogicalTapeReadExact_compat(state, LT_ARG, item, size);

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