diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-12-05 12:54:41 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-12-05 12:54:41 -0500 |
commit | 4398507dfafcbb92efd4fab816f3f8a1c0f34761 (patch) | |
tree | 67a10f402e4ffcbe4abd6e94dd8a230ab98a7777 | |
parent | a501fe5a971ed06c50f173406c4184b3d32cdf93 (diff) |
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
-rw-r--r-- | src/backend/tcop/postgres.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index c8c687d6f51..416cbd60909 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3674,6 +3674,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; |