]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix minor memory leaks in psql's tab completion.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 22 Jul 2022 14:53:26 +0000 (10:53 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 22 Jul 2022 14:53:26 +0000 (10:53 -0400)
Tang Haiying and Tom Lane

Discussion: https://postgr.es/m/OS0PR01MB6113EA19F05E217C823B4CCAFB909@OS0PR01MB6113.jpnprd01.prod.outlook.com

src/bin/psql/tab-complete.c
src/fe_utils/string_utils.c

index 080ce641d9342963d31c9711291a914ee9bf5680..a5a77af074e26f014e88f6eb830f1caeb86b8959 100644 (file)
@@ -5159,6 +5159,10 @@ _complete_from_query(const char *simple_query,
 
                /* Clean up */
                termPQExpBuffer(&query_buffer);
+               if (schemaname)
+                       free(schemaname);
+               if (objectname)
+                       free(objectname);
                free(e_object_like);
                if (e_schemaname)
                        free(e_schemaname);
index c3ea4fc186008ee1d57ac8bc271b911f63fbe4a3..f311bdd3ad5b7b5bc9484727ea294ba7c2680662 100644 (file)
@@ -1227,4 +1227,7 @@ patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf, PQExpBuffer schemabuf,
                        appendPQExpBufferStr(dbnamebuf, curbuf->data);
                termPQExpBuffer(curbuf);
        }
+
+       if (want_literal_dbname)
+               termPQExpBuffer(&left_literal);
 }