From: Alvaro Herrera Date: Sat, 7 Nov 2020 01:52:15 +0000 (-0300) Subject: Plug memory leak in index_get_partition X-Git-Tag: REL_12_5~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ad6a0c1bb1c5a041cadfed713ef6bcabd0955ab;p=thirdparty%2Fpostgresql.git 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 Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/20201105203606.GF22691@telsasoft.com --- diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index e96620e4018..c41fba7be3b 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -171,13 +171,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; }