BUG #18845: DEREF_OF_NULL.RET guc_malloc possibly returns NULL

PG Bug reporting form <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: pm91.arapov@gmail.com
Date: 2025-03-14T07:58:45Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18845
Logged by:          Nikita
Email address:      pm91.arapov@gmail.com
PostgreSQL version: 16.6
Operating system:   ubuntu 20.04
Description:        

guc_malloc possibly returns NULL, if no memory
I suggest the following patch fixing this issue

diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
--- a/src/backend/commands/user.c	(revision
a49ac80219c6f28c3cf3973f797de637329952da)
+++ b/src/backend/commands/user.c	(date 1740386879158)
@@ -2553,7 +2553,7 @@
 	pfree(rawstring);
 	list_free(elemlist);
 
-	result = (unsigned *) guc_malloc(LOG, sizeof(unsigned));
+	result = (unsigned *) guc_malloc(FATAL, sizeof(unsigned));
 	*result = options;
 	*extra = result;

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix guc_malloc calls for consistency and OOM checks