Fix memory leak in plperl_hash_from_tuple(), per report from Jean-Max Reymond.

This commit is contained in:
Tom Lane 2005-07-03 21:56:16 +00:00
parent ae9a07bf9e
commit bee9aef43b

@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.78 2005/06/22 16:45:51 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.79 2005/07/03 21:56:16 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
@ -1327,14 +1327,16 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
getTypeOutputInfo(tupdesc->attrs[i]->atttypid, getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
&typoutput, &typisvarlena); &typoutput, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall1(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput, attr));
attr));
sv = newSVpv(outputstr, 0); sv = newSVpv(outputstr, 0);
#if PERL_BCDVERSION >= 0x5006000L #if PERL_BCDVERSION >= 0x5006000L
if (GetDatabaseEncoding() == PG_UTF8) SvUTF8_on(sv); if (GetDatabaseEncoding() == PG_UTF8)
SvUTF8_on(sv);
#endif #endif
hv_store(hv, attname, namelen, sv, 0); hv_store(hv, attname, namelen, sv, 0);
pfree(outputstr);
} }
return newRV_noinc((SV *) hv); return newRV_noinc((SV *) hv);