From: Tom Lane Date: Thu, 5 Dec 2024 17:54:41 +0000 (-0500) Subject: Avoid low-probability crash on out-of-memory. X-Git-Tag: REL_14_16~69 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=d24eb0e91f3f7fc54ed4e56d93b26e2f8d52c1ce;p=postgresql.git 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 --- diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index bd8ad11421a..5d699f7ff7c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -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 */ *extra = malloc(sizeof(int)); + if (*extra == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); + *((int *) *extra) = flags; return true;