Re: [PATCH] dynahash: add memory allocation failure check
x4mmm@yandex-team.ru
From: Andrey Borodin <x4mmm@yandex-team.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: m.korotkov@postgrespro.ru,
pgsql-hackers@postgresql.org
Date: 2025-04-24T11:20:52Z
Lists: pgsql-hackers
> On 24 Apr 2025, at 00:42, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > - hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1); > + hashp = (HTAB *) MemoryContextAlloc(CurrentDynaHashCxt, > + sizeof(HTAB) + strlen(tabname) + 1); This seems correct to me. While fixing this maybe use MemoryContextAllocZero() instead of subsequent MemSet()? But this might unroll loop of unnecessary beautifications like DynaHashAlloc() calling Assert(MemoryContextIsValid(CurrentDynaHashCxt)) just before MemoryContextAllocExtended() will repeat same exercise. Best regards, Andrey Borodin.
Commits
-
Avoid possibly-theoretical OOM crash hazard in hash_create().
- bc19f63f8010 18.0 landed
- f45bdb13397f 16.9 landed
- e384118559ef 17.5 landed