Re: Fix calloc check if oom (PQcancelCreate) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Fix calloc check if oom (PQcancelCreate)
Date
Msg-id CAEudQAoxwuyBVMGG5PPpjddpeLgK8tFVu==OgMWk_DqhmSnjZA@mail.gmail.com
Whole thread Raw
In response to Re: Fix calloc check if oom (PQcancelCreate)  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: Fix calloc check if oom (PQcancelCreate)
List pgsql-hackers
Hi Daniel,

Em seg., 27 de mai. de 2024 às 10:23, Daniel Gustafsson <daniel@yesql.se> escreveu:
> On 27 May 2024, at 14:25, Ranier Vilela <ranier.vf@gmail.com> wrote:

> I think that commit 61461a3, left some oversight.
> The function *PQcancelCreate* fails in check,
> return of *calloc* function.
>
> Trivial fix is attached.

Agreed, this looks like a copy/paste from the calloc calls a few lines up.
Yeah.
 

> But, IMO, I think that has more problems.
> If any allocation fails, all allocations must be cleared.
> Or is the current behavior acceptable?

Since this is frontend library code I think we should free all the allocations
in case of OOM.
Agreed.

With v1 patch, it is handled.

best regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgsql: Add more SQL/JSON constructor functions
Next
From: Ranier Vilela
Date:
Subject: Fix use of possible uninitialized variable retval (src/pl/plpgsql/src/pl_handler.c)