Skip to content

Commit cd1c8b9

Browse files
committed
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 66e9444. Karina Litskevich Discussion: https://postgr.es/m/CACiT8iZ=atkguKVbpN4HmJFMb4+T9yEowF5JuPZG8W+kkZ9L6w@mail.gmail.com
1 parent 1168acb commit cd1c8b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/tcop/postgres.c

+5
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,11 @@ check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource so
34893489

34903490
/* Save the flags in *extra, for use by the assign function */
34913491
*extra = malloc(sizeof(int));
3492+
if (*extra == NULL)
3493+
ereport(ERROR,
3494+
(errcode(ERRCODE_OUT_OF_MEMORY),
3495+
errmsg("out of memory")));
3496+
34923497
*((int *) *extra) = flags;
34933498

34943499
return true;

0 commit comments

Comments
 (0)