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

Skip to content

Commit 970583a

Browse files
committed
Several routines in setrefs.c would crash on array refs
due to lack of check for recursing into a null subexpression.
1 parent 89cf930 commit 970583a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/optimizer/plan/setrefs.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.42 1999/04/26 00:37:46 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.43 1999/04/29 00:20:27 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -747,6 +747,9 @@ replace_agg_clause(Node *clause, List *subplanTargetList)
747747
List *t;
748748
List *agg_list = NIL;
749749

750+
if (clause == NULL)
751+
return NIL;
752+
750753
if (IsA(clause, Var))
751754
{
752755
TargetEntry *subplanVar;
@@ -864,6 +867,9 @@ del_agg_clause(Node *clause)
864867
{
865868
List *t;
866869

870+
if (clause == NULL)
871+
return clause;
872+
867873
if (IsA(clause, Var))
868874
return clause;
869875
else if (is_funcclause(clause))
@@ -942,6 +948,9 @@ check_having_qual_for_vars(Node *clause, List *targetlist_so_far)
942948
{
943949
List *t;
944950

951+
if (clause == NULL)
952+
return targetlist_so_far;
953+
945954
if (IsA(clause, Var))
946955
{
947956
RelOptInfo tmp_rel;
@@ -1035,6 +1044,9 @@ check_having_for_ungrouped_vars(Node *clause, List *groupClause)
10351044
{
10361045
List *t;
10371046

1047+
if (clause == NULL)
1048+
return;
1049+
10381050
if (IsA(clause, Var))
10391051
{
10401052
/* Ignore vars elsewhere in the having clause, since the

0 commit comments

Comments
 (0)