Hi hackers, When backporting 66e94448 to older versions it was forgotten to check malloc() result. In 16+ versions guc_malloc() is used to allocate memory and it checks if the result pointer is NULL, so there is no need to check it after guc_malloc(). Versions before 16 have no guc_malloc(), and malloc() is used instead, but we have to check if return value is NULL.
Please find attached patch for REL_15_STABLE. This should be fixed in older versions too. Best regards, Karina Litskevich Postgres Professional: http://postgrespro.com/
From f33e9823d6413b88c7a42f6509e5c796fd0bab95 Mon Sep 17 00:00:00 2001 From: Karina Litskevich <litskevichkar...@gmail.com> Date: Thu, 5 Dec 2024 19:31:27 +0300 Subject: [PATCH v1] Check if malloc returned NULL --- src/backend/tcop/postgres.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index c8c687d6f5..a9864f895b 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3674,6 +3674,12 @@ 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; -- 2.34.1