summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_custom.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-10-23 14:23:26 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-10-23 14:23:26 -0400
commite557c82759a3362d8fb618c798ca99ee90be96c5 (patch)
tree9d0e00657f8c343a6e949680b17abe0ed84ebca9 /src/bin/pg_dump/pg_backup_custom.c
parent9f9a04368f8055c1851f5071add393b380d1cc52 (diff)
Avoid memory leak in validation of a PL/Python trigger function.
If we're trying to perform check_function_bodies validation of a PL/Python trigger function, we create a new PLyProcedure, but we don't put it into the PLy_procedure_cache hash table. (Doing so would be useless, since we don't have the relation OID that is part of the cache key for a trigger function, so we could not make an entry that would be found by later uses.) However, we didn't think through what to do instead, with the result that the PLyProcedure was simply leaked. It would take a pretty large number of CREATE FUNCTION operations for this to amount to a serious problem, but it's easy to see the memory bloat if you do CREATE OR REPLACE FUNCTION in a loop. To fix, have PLy_procedure_get delete the new PLyProcedure and return NULL if it's not going to cache the PLyProcedure. I considered making plpython3_validator do the cleanup instead, which would be more natural. But then plpython3_validator would have to know the rules under which PLy_procedure_get returns a non-cached PLyProcedure, else it risks deleting something that's pointed to by a cache entry. On the whole it seems more robust to deal with the case inside PLy_procedure_get. Found by the new version of Coverity (nice catch!). In the end I feel this fix is more about satisfying Coverity than about fixing a real-world problem, so I'm not going to back-patch.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_custom.c')
0 files changed, 0 insertions, 0 deletions