From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Avoid incorrect allocation in buildIndexArray |
Date: | 2020-09-11 11:56:58 |
Message-ID: | CAEudQAr=855MX0uedcSOZ7LB1yEtrz1zeyD5JH-xJ-QT6Rdmiw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Sep 11, 2020 at 1:39 PM Daniel Gustafsson <daniel(at)yesql(dot)se>
wrote:
>
> Looking at a pg_dump patch I realized that when we call buildIndexArray
without
> having found objects to index, we still call pg_malloc with zero which in
turn
> mallocs 1 byte. The byte in question is of course negligable, but it does
seem
> cleaner to return early with NULL instead of returning an empty allocation
> which doesn't actually contain an index.
>
> Any reason not to bail early as per the attached?
+1
Since, it is protecting from invalid entries.
numObjs is int, the better it would be then.
+ if (numObjs <= 0)
+ return NULL;
+
regards,
Ranier Vilela
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2020-09-11 12:39:51 | pg_service.conf file with unknown parameters |
Previous Message | Julien Rouhaud | 2020-09-11 11:49:26 | Re: Avoid incorrect allocation in buildIndexArray |