public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ranier Vilela <[email protected]>
To: Daniel Gustafsson <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Fix resource leak (src/backend/libpq/be-secure-common.c)
Date: Wed, 10 Apr 2024 15:31:02 -0300
Message-ID: <CAEudQArcwFzYdGcRk8Tyf2ij0DR7mOoqSJejsa00+SkTjFNHSw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAEudQAqMeE0AHcOsOzZx51Z0eiFJAjhBPRFt+Bxi3ETXWen7ig@mail.gmail.com>
	<[email protected]>

Em ter., 2 de abr. de 2024 às 15:31, Daniel Gustafsson <[email protected]>
escreveu:

> > On 2 Apr 2024, at 20:13, Ranier Vilela <[email protected]> wrote:
>
> > Fix by freeing the pointer, like pclose_check (src/common/exec.c)
> similar case.
>
> Off the cuff, seems reasonable when loglevel is LOG.
>

Per Coverity.

Another case of resource leak, when loglevel is LOG.
In the function shell_archive_file (src/backend/archive/shell_archive.c)
The pointer *xlogarchcmd*  is not freed.

best regards,
Ranier Vilela


Attachments:

  [application/octet-stream] fix-resource-leak-shell_archive.patch (525B, ../CAEudQArcwFzYdGcRk8Tyf2ij0DR7mOoqSJejsa00+SkTjFNHSw@mail.gmail.com/3-fix-resource-leak-shell_archive.patch)
  download | inline diff:
diff --git a/src/backend/archive/shell_archive.c b/src/backend/archive/shell_archive.c
index 0925348bfe..506c5a30ad 100644
--- a/src/backend/archive/shell_archive.c
+++ b/src/backend/archive/shell_archive.c
@@ -125,9 +125,11 @@ shell_archive_file(ArchiveModuleState *state, const char *file,
 					 errdetail("The failed archive command was: %s",
 							   xlogarchcmd)));
 		}
+		pfree(xlogarchcmd);
 
 		return false;
 	}
+	pfree(xlogarchcmd);
 
 	elog(DEBUG1, "archived write-ahead log file \"%s\"", file);
 	return true;

view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Fix resource leak (src/backend/libpq/be-secure-common.c)
  In-Reply-To: <CAEudQArcwFzYdGcRk8Tyf2ij0DR7mOoqSJejsa00+SkTjFNHSw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox