Thread
Commits
-
Remove redundant memset() introduced by a0942f4.
- 4bfaea11d2d6 19 (unreleased) landed
-
Fix redundant memset after palloc0 in heap_form_minimal_tuple()
Chao Li <li.evan.chao@gmail.com> — 2025-11-04T09:05:29Z
Hi Hackers, While studying the other patch, I happened to notice this problem in heap_form_minimal_tuple(). The current code does both palloc0() and memset(0) in heap_form_minimal_tuple(): ``` /* * Allocate and zero the space needed. */ mem = palloc0(len + extra); memset(mem, 0, extra); tuple = (MinimalTuple) (mem + extra); ``` That looks like an oversight of a0942f4. To fix the problem, my first impression was to delete the memset(). But looking at a0942f4, I found a couple of other places that do the same pattern: palloc(len+extra) then memset(0, extra), so I think the correct fix should be changing the palloc0 to palloc. Best regards, Chao Li (Evan) --------------------- HighGo Software Co., Ltd. https://www.highgo.com/
-
Re: Fix redundant memset after palloc0 in heap_form_minimal_tuple()
Jeff Davis <pgsql@j-davis.com> — 2025-11-04T17:51:18Z
On Tue, 2025-11-04 at 17:05 +0800, Chao Li wrote: > The current code does both palloc0() and memset(0) > in heap_form_minimal_tuple(): Thank you, fixed. > To fix the problem, my first impression was to delete the memset(). > But looking at a0942f4, I found a couple of other places that do the > same pattern: palloc(len+extra) then memset(0, extra), so I think the > correct fix should be changing the palloc0 to palloc. The palloc0() is important because heap_fill_tuple() skips over alignment bytes. So I just removed the memset(). Regards, Jeff Davis