Re: libpq: Remove redundant null pointer checks before free()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq: Remove redundant null pointer checks before free()
Date: 2022-06-18 03:45:53
Message-ID: 1477430.1655523953@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Fri, Jun 17, 2022 at 09:03:23PM +0200, Peter Eisentraut wrote:
>> I'm pretty sure PostgreSQL code already depends on this behavior anyway.
>> The code just isn't consistent about it.

> In the frontend, I'd like to think that you are right and that we have
> already some places doing that.

We do, indeed.

> The backend is a different story,
> like in GetMemoryChunkContext(). That should be easy enough to check
> with some LD_PRELOAD wizardry, at least.

Huh? The proposal is to accept the fact that free() tolerates NULL,
and then maybe make pfree() tolerate it as well. I don't think that
that needs to encompass any other functions.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dong Wook Lee 2022-06-18 08:55:41 doc: pg_prewarm add configuration example
Previous Message Michael Paquier 2022-06-18 03:17:03 Re: libpq: Remove redundant null pointer checks before free()