1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Fix session-lifespan memory leak when a plperl function is redefined:

we have to tell Perl it can release its compiled copy of the function
text.  Noted by Alexey Klyukin.

Back-patch to 8.2 --- the problem exists further back, but this patch
won't work without modification, and it's probably not worth the trouble.
This commit is contained in:
Tom Lane
2009-11-29 21:02:34 +00:00
parent 26a13b7242
commit d4d4e95030

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL * plperl.c - perl as a procedural language for PostgreSQL
* *
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.123.2.8 2009/10/31 18:12:20 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.123.2.9 2009/11/29 21:02:34 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
@ -1502,10 +1502,13 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
if (!uptodate) if (!uptodate)
{ {
free(prodesc); /* are we leaking memory here? */
prodesc = NULL;
hash_search(plperl_proc_hash, internal_proname, hash_search(plperl_proc_hash, internal_proname,
HASH_REMOVE, NULL); HASH_REMOVE, NULL);
if (prodesc->reference)
SvREFCNT_dec(prodesc->reference);
free(prodesc->proname);
free(prodesc);
prodesc = NULL;
} }
} }