Re: Avoid incorrect allocation in buildIndexArray

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid incorrect allocation in buildIndexArray
Date: 2020-09-12 09:13:56
Message-ID: 20200912085410.GA9495@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)yesql(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2020-09-12 10:40:49 Re: Avoid incorrect allocation in buildIndexArray
Previous Message Pavel Stehule 2020-09-12 08:12:16 Re: proposal: possibility to read dumped table's name from file