Re: Avoid incorrect allocation in buildIndexArray - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Avoid incorrect allocation in buildIndexArray
Date
Msg-id 20200912085410.GA9495@paquier.xyz
Whole thread Raw
In response to Re: Avoid incorrect allocation in buildIndexArray  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: Avoid incorrect allocation in buildIndexArray  (Julien Rouhaud <rjuju123@gmail.com>)
List pgsql-hackers
On Fri, Sep 11, 2020 at 01:49:26PM +0200, Julien Rouhaud wrote:
> On Fri, Sep 11, 2020 at 1:39 PM Daniel Gustafsson <daniel@yesql.se> wrote:
>> Any reason not to bail early as per the attached?
>
> +1

Makes sense to me.  This has also the advantage to cause a crash if
there is an attempt to refer to those empty arrays in case of future
refactoring, which is rather defensive.  By looking at
findObjectByOid(), I can also see that we check for a negative number,
so I concur with Ranier's comment to check after that on top of 0.
If there are no objections, I'll apply that on HEAD.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: possibility to read dumped table's name from file
Next
From: Julien Rouhaud
Date:
Subject: Re: Avoid incorrect allocation in buildIndexArray