1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

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 66e94448a.

Karina Litskevich

Discussion: https://postgr.es/m/CACiT8iZ=atkguKVbpN4HmJFMb4+T9yEowF5JuPZG8W+kkZ9L6w@mail.gmail.com
This commit is contained in:
Tom Lane
2024-12-05 12:54:41 -05:00
parent 7d0b91a284
commit d24eb0e91f

View File

@ -3649,6 +3649,11 @@ check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource so
/* Save the flags in *extra, for use by the assign function */ /* Save the flags in *extra, for use by the assign function */
*extra = malloc(sizeof(int)); *extra = malloc(sizeof(int));
if (*extra == NULL)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
*((int *) *extra) = flags; *((int *) *extra) = flags;
return true; return true;