Fix (some of) pltcl memory usage
Fix (some of) pltcl memory usage

As reported by Bill Parker, PL/Tcl did not validate some malloc() calls
against NULL return.  Fix by using palloc() in a new long-lived memory
context instead.  This allows us to simplify error handling too, by
simply deleting the memory context instead of doing retail frees.

There's still a lot that could be done to improve PL/Tcl's memory
handling ...

This is pretty ancient, so backpatch all the way back.

Author: Michael Paquier and Álvaro Herrera
Discussion: 845f7e0d8fccc095222a9e191101a136ed175621@mail.gmail.com

zeroae/postgres-xl,zeroae/postgres-xl,zeroae/postgres-xl,zeroae/postgres-xl,zeroae/postgres-xl