pgsql: psql: Fix psql slash option leaks

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: psql: Fix psql slash option leaks
Date: 2026-08-19 03:40:53
Message-ID: E1wwXAZ-000000019X1-3tWx@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwEh3R3=1tx_a5=fTDJ+ycuwxWMEn6bG_Yt4B5P+hE7AVw@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_15_STABLE

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

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

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-08-19 03:41:03 pgsql: psql: Fix psql slash option leaks
Previous Message Fujii Masao 2026-08-19 03:40:52 pgsql: psql: Avoid returning oom_buffer from psql slash command scanner