psql: Fix psql slash option leaks

psql_scan_slash_option() returns a malloc'd string, but \getresults,
\gset in pipeline mode, \restrict, and \unrestrict did not free it
after consuming or copying the value.

Free these option strings after use.

Backpatch to all supported versions. In v17 and older, only \restrict
and \unrestrict are affected, so those branches need only that part of
the fix.

Author: Fujii Masao <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Discussion: 
https://postgr.es/m/CAHGQGwEh3R3=1tx_a5=ftdj+ycuwxwmen6bg_yt4b5p+he7...@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e3ad751e1f43a97a3ed5da358a938f8f87b6a4a1

Modified Files
--------------
src/bin/psql/command.c | 8 ++++++++
1 file changed, 8 insertions(+)

Reply via email to