Re: Move allocation size overflow handling to MemoryContextAllocExtended()? - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Move allocation size overflow handling to MemoryContextAllocExtended()?
Date
Msg-id CAB7nPqSTnj_6nFz=diYt7WciMSv4Dw=GF8T-4ffNXbH0QK2imw@mail.gmail.com
Whole thread Raw
In response to Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
Responses Re: Move allocation size overflow handling to MemoryContextAllocExtended()?  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Wed, Oct 5, 2016 at 8:56 AM, Andres Freund <andres@anarazel.de> wrote:
> That made me wonder if it's not actually a mistake for
> MemoryContextAllocExtended() size parameter to be declared
> Size/size_t. That prevents it from detecting such overflows, forcing
> code like the above on callsites.
>
> Comments?

The existing interface of MemoryContextAlloc do not care much about
anything except Size, so I'd just give the responsability to the
caller to do checks like queue != (Size) queue when queue is a uint64
for example. And I can see that your patch is using uint32 for
SH_TYPE->size.--
Michael



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Move allocation size overflow handling to MemoryContextAllocExtended()?
Next
From: Andres Freund
Date:
Subject: Re: Move allocation size overflow handling to MemoryContextAllocExtended()?