Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 362032f

Browse files
committed
Catch stack overflow when recursing in transformFromClauseItem().
Most parts of the parser can expect that the stack overflow check in transformExprRecurse() will trigger before things get desperate. However, transformFromClauseItem() can recurse directly to self without having analyzed any expressions, so it's possible to drive it to a stack-overrun crash. Add a check to prevent that. Per bug #17583 from Egor Chindyaskin. Back-patch to all supported branches. Richard Guo Discussion: https://postgr.es/m/[email protected]
1 parent 5dfb958 commit 362032f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/parser/parse_clause.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,9 @@ transformFromClauseItem(ParseState *pstate, Node *n,
10991099
RangeTblEntry **top_rte, int *top_rti,
11001100
List **namespace)
11011101
{
1102+
/* Guard against stack overflow due to overly deep subtree */
1103+
check_stack_depth();
1104+
11021105
if (IsA(n, RangeVar))
11031106
{
11041107
/* Plain relation reference, or perhaps a CTE reference */

0 commit comments

Comments
 (0)