From: Tom Lane Date: Fri, 22 Jul 2022 14:53:26 +0000 (-0400) Subject: Fix minor memory leaks in psql's tab completion. X-Git-Tag: REL_16_BETA1~2165 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=90474c16a7d24991586aa97c78b880fe9c072aba;p=postgresql.git Fix minor memory leaks in psql's tab completion. Tang Haiying and Tom Lane Discussion: https://postgr.es/m/OS0PR01MB6113EA19F05E217C823B4CCAFB909@OS0PR01MB6113.jpnprd01.prod.outlook.com --- diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 92207d2e160..5f06768085f 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -5158,6 +5158,8 @@ _complete_from_query(const char *simple_query, /* Clean up */ termPQExpBuffer(&query_buffer); + free(schemaname); + free(objectname); free(e_object_like); free(e_schemaname); free(e_ref_object); diff --git a/src/fe_utils/string_utils.c b/src/fe_utils/string_utils.c index f9ea08705af..a2fa7a0c26a 100644 --- a/src/fe_utils/string_utils.c +++ b/src/fe_utils/string_utils.c @@ -1225,4 +1225,7 @@ patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf, PQExpBuffer schemabuf, appendPQExpBufferStr(dbnamebuf, curbuf->data); termPQExpBuffer(curbuf); } + + if (want_literal_dbname) + termPQExpBuffer(&left_literal); }