Re: Change pfree to accept NULL argument

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Change pfree to accept NULL argument
Date: 2022-08-24 12:14:16
Message-ID: CAApHDvqxVq5zkYW7pz9TFN7NdiFtyR4Y4UEAm8FxSQVcOwnNpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 24 Aug 2022 at 23:07, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> One counter argument to that is for cases like list_free_deep().
> Right now if I'm not mistaken there's a bug (which I just noticed) in
> list_free_private() that would trigger if you have a List of Lists and
> one of the inner Lists is NIL. The code in list_free_private() just
> seems to go off and pfree() whatever is stored in the element, which I
> think would crash if it found a NIL List. If pfree() was to handle
> NULLs at least that wouldn't have been a crash, but in reality, we
> should probably fix that with recursion if we detect the element IsA
> List type. If we don't use recursion, then the "free" does not seem
> very "deep". (Or maybe it's too late to make it go deeper as it might
> break existing code.)

Hmm, that was a false alarm. It seems list_free_deep() can't really
handle freeing sublists as the list elements might be non-Node types,
which of course have no node tag, so we can't check for sub-Lists.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-08-24 12:30:16 Re: Logical replication support for generic wal record
Previous Message Robert Haas 2022-08-24 12:13:36 Re: standby promotion can create unreadable WAL