dbase_redo: Fix Valgrind-reported memory leak
authorÁlvaro Herrera <[email protected]>
Sat, 11 Oct 2025 14:39:22 +0000 (16:39 +0200)
committerÁlvaro Herrera <[email protected]>
Sat, 11 Oct 2025 14:39:22 +0000 (16:39 +0200)
Introduced by my (Álvaro's) commit 9e4f914b5eba, which was itself
backpatched to pg10, though only pg15 and up contain the problem
because of commit 9c08aea6a309.

This isn't a particularly significant leak, but given the fix is
trivial, we might as well backpatch to all branches where it applies, so
do that.

Author: Nathan Bossart <[email protected]>
Reported-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/x4odfdlrwvsjawscnqsqjpofvauxslw7b4oyvxgt5owoyf4ysn@heafjusodrz7

src/backend/commands/dbcommands.c

index a100d5b37e09760afbd144ab1df35e748320991c..f39709666ea952234400dc06ffac7d378c5be325 100644 (file)
@@ -3289,6 +3289,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,