Avoid incorrect allocation in buildIndexArray

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Avoid incorrect allocation in buildIndexArray
Date: 2020-09-11 11:38:29
Message-ID: 26C43E58-BDD0-4F1A-97CC-4A07B52E32C5@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

cheers ./daniel

Attachment Content-Type Size
buildindexarrayalloc.patch application/octet-stream 988 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2020-09-11 11:49:26 Re: Avoid incorrect allocation in buildIndexArray
Previous Message Daniel Gustafsson 2020-09-11 11:18:52 Re: TDE (Transparent Data Encryption) supported ?