From 76e85b22504e34d15e4102631f9caba755c43869 Mon Sep 17 00:00:00 2001
From: tanghy <tanghy.fnst@fujitsu.com>
Date: Tue, 19 Jul 2022 17:15:05 +0900
Subject: [PATCH v1] fix the memory leak in validateSQLNamePattern


diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 88d92a08ae..0ce38e4b4c 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -6023,15 +6023,18 @@ validateSQLNamePattern(PQExpBuffer buf, const char *pattern, bool have_where,
 		if (PQdb(pset.db) == NULL)
 		{
 			pg_log_error("You are currently not connected to a database.");
+			termPQExpBuffer(&dbbuf);
 			return false;
 		}
 		if (strcmp(PQdb(pset.db), dbbuf.data) != 0)
 		{
 			pg_log_error("cross-database references are not implemented: %s",
 						 pattern);
+			termPQExpBuffer(&dbbuf);
 			return false;
 		}
 	}
+	termPQExpBuffer(&dbbuf);
 	return true;
 }
 
-- 
2.33.0.windows.2

