You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by re...@apache.org on 2025/12/22 10:56:54 UTC

(cloudberry) 01/01: Beautify `UpdateCatalogForStandbyPromotion`.

This is an automated email from the ASF dual-hosted git repository.

reshke pushed a commit to branch fix_GetDatabasePath_leak
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 24c4f39d838310760cf5f65f0ee9fede07b05c5b
Author: reshke <re...@double.cloud>
AuthorDate: Mon Dec 22 10:53:22 2025 +0000

    Beautify `UpdateCatalogForStandbyPromotion`.
    
    Some variable declaration to beginning of function to
    enforce C90 and long-standing coding practice of PostgreSQL.
    Also, be tidy, and release memory allocated in GetDatabasePath.
    This is not a real memory leak, as standby promotion happends
    only once (until next restart).
    
    Per coverity report 529246.
---
 src/backend/access/transam/xlog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 034aeb6473b..cff69879aa1 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6528,6 +6528,7 @@ static void
 UpdateCatalogForStandbyPromotion(void)
 {
 	GpRoleValue old_role;
+	char *fullpath;
 	/*
 	 * NOTE: The following initialization logic was borrowed from ftsprobe.
 	 */
@@ -6599,8 +6600,6 @@ UpdateCatalogForStandbyPromotion(void)
 	 */
 	RelationCacheInitializePhase2();
 
-	char *fullpath;
-
 	/*
 	 * In order to access the catalog, we need a database, and a
 	 * tablespace; our access to the heap is going to be slightly
@@ -6620,6 +6619,7 @@ UpdateCatalogForStandbyPromotion(void)
 	fullpath = GetDatabasePath(MyDatabaseId, MyDatabaseTableSpace);
 
 	SetDatabasePath(fullpath);
+	pfree(fullpath);
 
 	RelationCacheInitializePhase3();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org