From be3517969c9cdcb55f5c754d849572b30abb4c3a Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 16 Nov 2022 12:27:46 +0100 Subject: [PATCH v25 7/9] perminfoindex is unsigned; also, test for 0 --- src/backend/parser/parse_relation.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 5fd01965a4..92ead7d8be 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -3749,14 +3749,15 @@ GetRTEPermissionInfo(List *rtepermlist, RangeTblEntry *rte) { RTEPermissionInfo *perminfo; - Assert(rte->perminfoindex > 0); - if (rte->perminfoindex > list_length(rtepermlist)) - elog(ERROR, "invalid perminfoindex %u in RTE with relid %u", + if (rte->perminfoindex == 0 || + rte->perminfoindex > list_length(rtepermlist)) + elog(ERROR, "invalid perminfoindex %d in RTE with relid %u", rte->perminfoindex, rte->relid); perminfo = list_nth_node(RTEPermissionInfo, rtepermlist, rte->perminfoindex - 1); if (perminfo->relid != rte->relid) elog(ERROR, "permission info at index %u (with relid=%u) does not match requested RTE (with relid=%u)", rte->perminfoindex, perminfo->relid, rte->relid); + return perminfo; } -- 2.30.2