Skip to content

Commit 8f68671

Browse files
committed
[PGPRO-3725] zero out garbage in append_rel_array if we allocate it.
Since 1d9056f563f3 (who uses AppendRelInfo* existence as a mark this rel is child) in 11.7 this led to (known) random segfaults.
1 parent fa068e7 commit 8f68671

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/hooks.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,13 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
498498
irange_len * sizeof(RangeTblEntry *));
499499

500500
#if PG_VERSION_NUM >= 110000
501-
/* Make sure append_rel_array is wide enough */
501+
/*
502+
* Make sure append_rel_array is wide enough; if it hasn't been
503+
* allocated previously, care to zero out [0; current_len) part.
504+
*/
502505
if (root->append_rel_array == NULL)
503-
root->append_rel_array = (AppendRelInfo **) palloc0(0);
506+
root->append_rel_array = (AppendRelInfo **)
507+
palloc0(current_len * sizeof(AppendRelInfo *));
504508
root->append_rel_array = (AppendRelInfo **)
505509
repalloc(root->append_rel_array,
506510
new_len * sizeof(AppendRelInfo *));

0 commit comments

Comments
 (0)