Skip to content

Commit

Permalink
[PGPRO-3725] zero out garbage in append_rel_array if we allocate it.
Browse files Browse the repository at this point in the history
Since 1d9056f563f3 (who uses AppendRelInfo* existence as a mark this rel is
child) in 11.7 this led to (known) random segfaults.
  • Loading branch information
arssher committed Apr 2, 2020
1 parent fa068e7 commit 8f68671
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,13 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
irange_len * sizeof(RangeTblEntry *));

#if PG_VERSION_NUM >= 110000
/* Make sure append_rel_array is wide enough */
/*
* Make sure append_rel_array is wide enough; if it hasn't been
* allocated previously, care to zero out [0; current_len) part.
*/
if (root->append_rel_array == NULL)
root->append_rel_array = (AppendRelInfo **) palloc0(0);
root->append_rel_array = (AppendRelInfo **)
palloc0(current_len * sizeof(AppendRelInfo *));
root->append_rel_array = (AppendRelInfo **)
repalloc(root->append_rel_array,
new_len * sizeof(AppendRelInfo *));
Expand Down

0 comments on commit 8f68671

Please sign in to comment.