diff options
author | Alvaro Herrera | 2020-11-07 01:52:16 +0000 |
---|---|---|
committer | Alvaro Herrera | 2020-11-07 01:52:16 +0000 |
commit | 623644f02cbde7ad3812b201bd36213a206c3341 (patch) | |
tree | 7a102416ec6b33d9af89e0d1181fd92d5f65349d /src/backend/catalog/partition.c | |
parent | a05dbf477b0ef173adb1ae5d004cbeb0cf400b66 (diff) |
Plug memory leak in index_get_partition
The list of indexes was being leaked when asked for an index that
doesn't have an index partition in the table partition. Not a common
case admittedly --and in most cases where it occurs, caller throws an
error anyway-- but worth fixing for cleanliness and in case any
third-party code is calling this function.
While at it, remove use of lfirst_oid() to obtain a value we already
have.
Author: Justin Pryzby <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/catalog/partition.c')
-rw-r--r-- | src/backend/catalog/partition.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 239ac017fa6..4dfac39adfe 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -170,13 +170,14 @@ index_get_partition(Relation partition, Oid indexId) ReleaseSysCache(tup); if (!ispartition) continue; - if (get_partition_parent(lfirst_oid(l)) == indexId) + if (get_partition_parent(partIdx) == indexId) { list_free(idxlist); return partIdx; } } + list_free(idxlist); return InvalidOid; } |