aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistutil.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-06-01 14:48:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-06-01 14:48:35 -0400
commitc6f7f11d8f4cd28a83c638c3bc3758c1c091657b (patch)
tree79a63d0867100312c673683aef87eb8728058858 /src/backend/access/gist/gistutil.c
parente5a3c9d9b5ce535151d3a7e3173e8d27d2d8cd58 (diff)
downloadpostgresql-c6f7f11d8f4cd28a83c638c3bc3758c1c091657b.tar.gz
postgresql-c6f7f11d8f4cd28a83c638c3bc3758c1c091657b.zip
Fix edge-case resource leaks in PL/Python error reporting.
PLy_elog_impl and its subroutine PLy_traceback intended to avoid leaking any PyObject reference counts, but their coverage of the matter was sadly incomplete. In particular, out-of-memory errors in most of the string-construction subroutines could lead to reference count leaks, because those calls were outside the PG_TRY blocks responsible for dropping reference counts. Fix by (a) adjusting the scopes of the PG_TRY blocks, and (b) moving the responsibility for releasing the reference counts of the traceback-stack objects to PLy_elog_impl. This requires some additional "volatile" markers, but not too many. In passing, fix an ancient thinko: use of the "e_module_o" PyObject was guarded by "if (e_type_s)", where surely "if (e_module_o)" was meant. This would only have visible consequences if the "__name__" attribute were present but the "__module__" attribute wasn't, which apparently never happens; but someday it might. Rearranging the PG_TRY blocks requires indenting a fair amount of code one more tab stop, which I'll do separately for clarity. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/2954090.1748723636@sss.pgh.pa.us Backpatch-through: 13
Diffstat (limited to 'src/backend/access/gist/gistutil.c')
0 files changed, 0 insertions, 0 deletions