]> granicus.if.org Git - postgresql/commit
Fix memory leaks in record_out() and record_send().
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Nov 2012 19:44:56 +0000 (14:44 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Nov 2012 19:44:56 +0000 (14:44 -0500)
commitc027d84c81d5e07e58cd25ea38805d6f1ae4dfcd
treed8abf2e6d6e848e6749af0b143d773c9588b3584
parent2faab1af69de2a04bf98e79638393493c4867949
Fix memory leaks in record_out() and record_send().

record_out() leaks memory: it fails to free the strings returned by the
per-column output functions, and also is careless about detoasted values.
This results in a query-lifespan memory leakage when returning composite
values to the client, because printtup() runs the output functions in the
query-lifespan memory context.  Fix it to handle these issues the same way
printtup() does.  Also fix a similar leakage in record_send().

(At some point we might want to try to run output functions in
shorter-lived memory contexts, so that we don't need a zero-leakage policy
for them.  But that would be a significantly more invasive patch, which
doesn't seem like material for back-patching.)

In passing, use appendStringInfoCharMacro instead of appendStringInfoChar
in the innermost data-copying loop of record_out, to try to shave a few
cycles from this function's runtime.

Per trouble report from Carlos Henrique Reimer.  Back-patch to all
supported versions.
src/backend/utils/adt/rowtypes.c