[PATCH] dynahash: add memory allocation failure check

m.korotkov@postgrespro.ru

From: m.korotkov@postgrespro.ru
To: pgsql-hackers@postgresql.org
Date: 2025-04-23T08:32:42Z
Lists: pgsql-hackers

Attachments

Hi all,
I found a case of potential NULL pointer dereference.
In src/backend/utils/hash/dynahash.c in function HTAB *hash_create() the 
result of the DynaHashAlloc() is used unsafely.
The function DynaHashAlloc() calls MemoryContextAllocExtended() with 
MCXT_ALLOC_NO_OOM and can return a NULL pointer.
Added the pointer check for avoiding a potential problem.
---
Best regards, Korotkov Maksim
PostgresPro
m.korotkov@postgrespro.ru

Commits

  1. Avoid possibly-theoretical OOM crash hazard in hash_create().