summaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-12-05 12:54:41 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-12-05 12:54:41 -0500
commitcd1c8b992e9f8774f9e08b2c7f668067bfe7e621 (patch)
tree5dc36eb743e1f77cbe7e97f330961b5e0bf9fe75 /src/backend/tcop/postgres.c
parent1168acbca475d48f745b345f69389df11f2396aa (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
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index ec630b44916..8ad28dce2b7 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3489,6 +3489,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;