Re: Use pg_malloc macros in src/fe_utils

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Henrik TJ <henrik(at)0x48(dot)dk>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use pg_malloc macros in src/fe_utils
Date: 2026-03-03 03:44:41
Message-ID: f5a933ea-0901-47a3-bc56-18c42b2ab0b2@proxel.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/27/26 11:00 AM, Michael Paquier wrote:
> On Fri, Feb 27, 2026 at 02:15:46AM +0100, Andreas Karlsson wrote:
>> 1. What should we do about when we allocate a an array of characters? Would
>> it make sense to use pg_array_alloc() or would that jsut be silly? For
>> example:
>>
>> -pad = (char *) pg_malloc(l + 1);
>> +pad = pg_malloc_array(char, l + 1);
>
> I can see that tar_get_file_name() has been changed in 0001, which is
> fine, so I have merged the change from 0002 in
> dir_get_file_name()@walmethods.c into 0001, for consistency. I don't
> really have a strong opinion about the rest of 0002, TBH.

Then I think we should skip it. If someone else wants to fix it in the
future they are free to do so.

>> 2. I found a small and harmless thinko. The buffer in verify_tar_file() is
>> actually a char * but for some reason the code did the following:
>>
>> buffer = pg_malloc(READ_CHUNK_SIZE * sizeof(uint8));
>>
>> What should we do about it? Just skip the "sizof(uint8)"?
>
> This one has already been discussed, see here:
> https://www.postgresql.org/message-id/aUJ2zxgPCaVsVi2a@ip-10-97-1-34.eu-west-3.compute.internal
> The story is a bit larger than this single allocation, as it impacts
> the meaning of the surrounding routines with backup manifests.

Thanks for the link!

> And applied 0001 after double-checking it. Thanks.

Thanks!

--
Andreas Karlsson
Percona

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2026-03-03 04:02:53 RE: BUG: Former primary node might stuck when started as a standby
Previous Message Andreas Karlsson 2026-03-03 03:39:43 Re: [BUGFIX] Fix crash due to sizeof bug in RegisterExtensionExplainOption