Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d24eb0e

Browse files
committedDec 5, 2024
Avoid low-probability crash on out-of-memory.
check_restrict_nonsystem_relation_kind() correctly uses guc_malloc() in v16 and later. But in older branches it must use malloc() directly, and it forgot to check for failure return. Faulty backpatching of 66e9444. Karina Litskevich Discussion: https://postgr.es/m/CACiT8iZ=atkguKVbpN4HmJFMb4+T9yEowF5JuPZG8W+kkZ9L6w@mail.gmail.com
1 parent 7d0b91a commit d24eb0e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎src/backend/tcop/postgres.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,6 +3649,11 @@ check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource so
36493649

36503650
/* Save the flags in *extra, for use by the assign function */
36513651
*extra = malloc(sizeof(int));
3652+
if (*extra == NULL)
3653+
ereport(ERROR,
3654+
(errcode(ERRCODE_OUT_OF_MEMORY),
3655+
errmsg("out of memory")));
3656+
36523657
*((int *) *extra) = flags;
36533658

36543659
return true;

0 commit comments

Comments
 (0)
Failed to load comments.