Fix memory leak in printtup.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 18 Mar 2019 21:54:24 +0000 (17:54 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 18 Mar 2019 21:54:41 +0000 (17:54 -0400)
commitf2004f19ed9c9228d3ea2b12379ccb4b9212641f
treee624dbef56a9b39f12341011d1a8b1ef0811aa24
parent11180a5015e9c6299ee732fa587b3a8bc6dca6b2
Fix memory leak in printtup.c.

Commit f2dec34e1 changed things so that printtup's output stringinfo
buffer was allocated outside the per-row temporary context, not inside
it.  This creates a need to free that buffer explicitly when the temp
context is freed, but that was overlooked.  In most cases, this is all
happening inside a portal or executor context that will go away shortly
anyhow, but that's not always true.  Notably, the stringinfo ends up
getting leaked when JDBC uses row-at-a-time fetches.  For a query
that returns wide rows, that adds up after awhile.

Per bug #15700 from Matthias Otterbach.  Back-patch to v11 where the
faulty code was added.

Discussion: https://postgr.es/m/15700-8c408321a87d56bb@postgresql.org
src/backend/access/common/printtup.c