From: Michael Paquier Date: Mon, 6 Jul 2026 00:32:30 +0000 (+0900) Subject: amcheck: Fix memory leak with gin_index_check() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f8ab91c11ebf3d6521e2c9d67e321b1256f364c;p=thirdparty%2Fpostgresql.git amcheck: Fix memory leak with gin_index_check() "prev_tuple" was overwritten with a new tuple coming from CopyIndexTuple() on each loop, leaking memory for every tuple processed on entry tree pages. The function uses a dedicated memory context, but this could leave unused large areas of memory while processing a large GIN index, the larger the worse. Oversight in 14ffaece0fb5. Author: Kirill Reshke Reviewed-by: Ewan Young Discussion: https://postgr.es/m/CALdSSPjTS6TYe5=5NfMUBYZyQu5cn=ABL6K5_OZjzGWqnwXeBw@mail.gmail.com Backpatch-through: 18 --- diff --git a/contrib/amcheck/verify_gin.c b/contrib/amcheck/verify_gin.c index c615d950736..0455ea2a2c1 100644 --- a/contrib/amcheck/verify_gin.c +++ b/contrib/amcheck/verify_gin.c @@ -638,6 +638,9 @@ gin_check_parent_keys_consistency(Relation rel, pfree(ipd); } + if (prev_tuple) + pfree(prev_tuple); + prev_tuple = CopyIndexTuple(idxtuple); prev_attnum = current_attnum; }