Re: memory leak in dbase_redo() - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: memory leak in dbase_redo()
Date
Msg-id aOfNemaM46lxHND8@nathan
Whole thread Raw
In response to memory leak in dbase_redo()  (Andres Freund <andres@anarazel.de>)
Responses Re: memory leak in dbase_redo()
Re: memory leak in dbase_redo()
List pgsql-hackers
On Thu, Oct 09, 2025 at 08:08:05AM -0400, Andres Freund wrote:
> And I think it is right. XLOG_DBASE_CREATE_FILE_COPY is careful to
> pfree(parent_path), but XLOG_DBASE_CREATE_WAL_LOG isn't.

It looks like this was introduced by commit 9e4f914, which was
back-patched, but the code path in question first appears in v15.  So,
presumably something like the following needs to be back-patched that far.
I can take care of it unless someone else wants it.

diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2793fd83771..4d65e8c46c2 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -3375,6 +3375,7 @@ dbase_redo(XLogReaderState *record)
         parent_path = pstrdup(dbpath);
         get_parent_directory(parent_path);
         recovery_create_dbdir(parent_path, true);
+        pfree(parent_path);

         /* Create the database directory with the version file. */
         CreateDirAndVersionFile(dbpath, xlrec->db_id, xlrec->tablespace_id,

-- 
nathan



pgsql-hackers by date:

Previous
From: Greg Burd
Date:
Subject: Re: Fix for compiler warning triggered in WinGetFuncArgInPartition()
Next
From: Robert Haas
Date:
Subject: Re: Should we update the random_page_cost default value?