From 661ab4e185784db79c194b5758555b1db3f30483 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 9 Apr 2024 09:07:14 -0400 Subject: Fix some memory leaks associated with parsing json and manifests Coverity complained about not freeing some memory associated with incrementally parsing backup manifests. To fix that, provide and use a new shutdown function for the JsonManifestParseIncrementalState object, in line with a suggestion from Tom Lane. While analysing the problem, I noticed a buglet in freeing memory for incremental json lexers. To fix that remove a bogus condition on freeing the memory allocated for them. --- src/backend/backup/basebackup_incremental.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/backend/backup/basebackup_incremental.c') diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c index 4962bf1529e..330a2294011 100644 --- a/src/backend/backup/basebackup_incremental.c +++ b/src/backend/backup/basebackup_incremental.c @@ -241,6 +241,9 @@ FinalizeIncrementalManifest(IncrementalBackupInfo *ib) pfree(ib->buf.data); ib->buf.data = NULL; + /* Done with inc_state, so release that memory too */ + json_parse_manifest_incremental_shutdown(ib->inc_state); + /* Switch back to previous memory context. */ MemoryContextSwitchTo(oldcontext); } -- cgit v1.2.3