0001-Fix-use-after-free-in-expand_partitioned_rtentry.patch
text/x-patch
Filename: 0001-Fix-use-after-free-in-expand_partitioned_rtentry.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Fix dangling pointer in while condition
| File | + | − |
|---|---|---|
| src/backend/optimizer/util/inherit.c | 3 | 4 |
From a2329fe9319bf7d68723c3cdebe358595ff180b9 Mon Sep 17 00:00:00 2001
From: Bernd Reiss <bd_reiss@gmx.at>
Date: Thu, 28 Aug 2025 22:44:10 +0200
Subject: [PATCH] Fix dangling pointer in while condition
---
src/backend/optimizer/util/inherit.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/backend/optimizer/util/inherit.c b/src/backend/optimizer/util/inherit.c
index 30d158069e3..856d5959d10 100644
--- a/src/backend/optimizer/util/inherit.c
+++ b/src/backend/optimizer/util/inherit.c
@@ -322,7 +322,6 @@ expand_partitioned_rtentry(PlannerInfo *root, RelOptInfo *relinfo,
PlanRowMark *top_parentrc, LOCKMODE lockmode)
{
PartitionDesc partdesc;
- Bitmapset *live_parts;
int num_live_parts;
int i;
@@ -356,10 +355,10 @@ expand_partitioned_rtentry(PlannerInfo *root, RelOptInfo *relinfo,
* that survive pruning. Below, we will initialize child objects for the
* surviving partitions.
*/
- relinfo->live_parts = live_parts = prune_append_rel_partitions(relinfo);
+ relinfo->live_parts = prune_append_rel_partitions(relinfo);
/* Expand simple_rel_array and friends to hold child objects. */
- num_live_parts = bms_num_members(live_parts);
+ num_live_parts = bms_num_members(relinfo->live_parts);
if (num_live_parts > 0)
expand_planner_arrays(root, num_live_parts);
@@ -378,7 +377,7 @@ expand_partitioned_rtentry(PlannerInfo *root, RelOptInfo *relinfo,
* table itself, because it's not going to be scanned.
*/
i = -1;
- while ((i = bms_next_member(live_parts, i)) >= 0)
+ while ((i = bms_next_member(relinfo->live_parts, i)) >= 0)
{
Oid childOID = partdesc->oids[i];
Relation childrel;
--
2.51.0