Re: Collection of memory leaks for ECPG driver

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org>
Subject: Re: Collection of memory leaks for ECPG driver
Date: 2015-06-13 04:02:40
Message-ID: 4940.1434168160@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> On Fri, Jun 12, 2015 at 10:01 PM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
>> More seriously, though, does anyone know of any platform where free(NULL) is *not* a noop?

> I recall reading that some past versions of SunOS crashed, but it is
> rather old...

Yeah, SunOS 4.x had issues here, but it's long dead. More to the point,
both C89 and Single Unix Spec v2 clearly say that free(NULL) is a no-op;
and it's been many years since we agreed that we had no interest in
supporting platforms that didn't meet at least those minimum standards.
So there is no need to worry about any code of ours that does free(NULL).

But having said that, I would not be in a hurry to remove any existing
if-guards for the case. For one thing, it makes the code look more
similar to backend code that uses palloc/pfree, where we do *not* allow
pfree(NULL). There's also the point that changing longstanding code
creates back-patching hazards, so unless there's a clear gain it's best
not to.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-06-13 04:10:17 Re: Time to fully remove heap_formtuple() and friends?
Previous Message Tom Lane 2015-06-13 03:47:09 Re: Time to fully remove heap_formtuple() and friends?