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 <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to