_int_bool.c.patch   [plain text]


--- postgresql-9.0.3/contrib/intarray/_int_bool.c      2011-01-27 18:21:31.000000000 -0800 
+++ postgresql/contrib/intarray/_int_bool.c    2011-04-03 09:38:09.000000000 -0700 
@@ -56,6 +56,8 @@
 	int4		num;
 } WORKSTATE;
 
+#define STACKDEPTH      16
+
 /*
  * get token from query string
  */
@@ -90,7 +92,10 @@
 				}
 				else if (*(state->buf) == '(')
 				{
-					state->count++;
+					if (state->count++ > STACKDEPTH)
+						ereport(ERROR,
+							(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
+							errmsg("statement too complex")));
 					(state->buf)++;
 					return OPEN;
 				}
@@ -160,8 +165,6 @@
 	state->num++;
 }
 
-#define STACKDEPTH	16
-
 /*
  * make polish notation of query
  */