public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Nathan Bossart <[email protected]>
Cc: Jeff Davis <[email protected]>
Cc: [email protected]
Subject: Re: Fix minor memory leak in connection string validation
Date: Fri, 12 Jan 2024 22:18:55 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <20240113023705.GA4039878@nathanxps13>
References: <[email protected]>
	<20240113023705.GA4039878@nathanxps13>

Nathan Bossart <[email protected]> writes:
> On Fri, Jan 12, 2024 at 03:06:26PM -0800, Jeff Davis wrote:
>> It makes me wonder if we should use the resowner mechanism to track
>> pointers to malloc'd memory. Then we could use a standard pattern for
>> these kinds of cases, and it would also catch more remote issues, like
>> if a pstrdup() fails in an error path (which can happen a few lines up
>> if the parse fails).

> That seems worth exploring.

I'm pretty dubious about adding overhead for that, mainly because
most of the direct callers of malloc in a backend are going to be
code that's not under our control.  Modifying the callers that we
do control is not going to give a full solution, and could well be
outright misleading.

> Another option could be to surround this with PG_TRY/PG_FINALLY, but your
> patch seems sufficient, too.

Yeah, seems fine for now.  If that function grows any more complexity
then we could think about using PG_TRY.

			regards, tom lane






view thread (2+ messages)

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], [email protected]
  Subject: Re: Fix minor memory leak in connection string validation
  In-Reply-To: <[email protected]>

* 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