pgbackrest.git / summary / log / commit / refs
commit 40ef64f2be60fb947cf68aae2bb7d510ab36c8ec
Author: David Steele <david@pgmasters.net>
Date: Mon Apr 25 16:59:46 2022 +0000
Fix memory leaks in archivePushFile().
The errorList is only used when throwing an error and the joined list is not needed after the error is thrown, so put both in the temp mem context.
src/command/archive/push/file.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/command/archive/push/file.c b/src/command/archive/push/file.c
index 06b794a5b..592064ffc 100644
--- a/src/command/archive/push/file.c
+++ b/src/command/archive/push/file.c
@@ -116,10 +116,11 @@ archivePushFile(
ASSERT(lstSize(repoList) > 0);
ArchivePushFileResult result = {.warnList = strLstNew()};
- StringList *errorList = strLstDup(priorErrorList);
MEM_CONTEXT_TEMP_BEGIN()
{
+ StringList *const errorList = strLstDup(priorErrorList);
+
// Is this a WAL segment?
bool isSegment = walIsSegment(archiveFile);
@@ -322,13 +323,13 @@ archivePushFile(
}
}
}
+
+ // Throw any errors, even if some pushes were successful. It is important that PostgreSQL receives an error so it does not
+ // remove the file.
+ if (strLstSize(errorList) > 0)
+ THROW_FMT(CommandError, CFGCMD_ARCHIVE_PUSH " command encountered error(s):\n%s", strZ(strLstJoin(errorList, "\n")));
}
MEM_CONTEXT_TEMP_END();
- // Throw any errors, even if some pushes were successful. It is important that PostgreSQL receives an error so it does not
- // remove the file.
- if (strLstSize(errorList) > 0)
- THROW_FMT(CommandError, CFGCMD_ARCHIVE_PUSH " command encountered error(s):\n%s", strZ(strLstJoin(errorList, "\n")));
-
FUNCTION_LOG_RETURN_STRUCT(result);
}
[parent: 774db650868c]