]> granicus.if.org Git - postgresql/commit
Fix two memory leaks around force-storing tuples in slots.
authorAndres Freund <andres@anarazel.de>
Fri, 19 Apr 2019 18:33:37 +0000 (11:33 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 19 Apr 2019 18:39:56 +0000 (11:39 -0700)
commit88e6ad3054ddd5aa0dee12e5def2c335fe92a414
tree37320de1df0f431fd5f3553b94c1f8f146efb621
parent4d5840cea96d7f893389664dd423716b38fded7a
Fix two memory leaks around force-storing tuples in slots.

As reported by Tom, when ExecStoreMinimalTuple() had to perform a
conversion to store the minimal tuple in the slot, it forgot to
respect the shouldFree flag, and leaked the tuple into the current
memory context if true.  Fix that by freeing the tuple in that case.

Looking at the relevant code made me (Andres) realize that not having
the shouldFree parameter to ExecForceStoreHeapTuple() was a bad
idea. Some callers had to locally implement the necessary logic, and
in one case it was missing, creating a potential per-group leak in
non-hashed aggregation.

The choice to not free the tuple in ExecComputeStoredGenerated() is
not pretty, but not introduced by this commit - I'll start a separate
discussion about it.

Reported-By: Tom Lane
Discussion: https://postgr.es/m/366.1555382816@sss.pgh.pa.us
contrib/postgres_fdw/postgres_fdw.c
src/backend/commands/trigger.c
src/backend/executor/execTuples.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeIndexonlyscan.c
src/backend/executor/nodeModifyTable.c
src/include/executor/tuptable.h