]> granicus.if.org Git - graphviz/commitdiff
double size of graph stack and error on overflow
authorellson <devnull@localhost>
Sun, 21 Sep 2008 02:10:38 +0000 (02:10 +0000)
committerellson <devnull@localhost>
Sun, 21 Sep 2008 02:10:38 +0000 (02:10 +0000)
lib/graph/parser.y

index 4bb215e7b4ccfa347914b6db8cfeb6d082a94be2..b5d3db453701cae5111cd962ad2fccc15fd2ae65 100644 (file)
@@ -31,8 +31,14 @@ static Agraph_t              *G;
 static Agnode_t                *N;
 static Agedge_t                *E;
 static objstack_t      *SP;
-static Agraph_t                *Gstack[32];
-static int                     GSP;
+#if 0
+static Agraph_t                **Gstack;
+static int             GSP_allocated, GSP;
+#else
+#define GSTACK_SIZE 64
+static Agraph_t         *Gstack[GSTACK_SIZE];
+static int             GSP;
+#endif
 
 static void subgraph_warn (void)
 {
@@ -44,8 +50,19 @@ static void subgraph_warn (void)
 
 static void push_subg(Agraph_t *g)
 {
+#if 0
+       if (GSP >= GSP_allocated) {
+               GSP_allocated += 32;
+               Gstack = realloc(Gstack, sizeof(Agraph_t*));
+       }
+#else
+       if (GSP == GSTACK_SIZE) {
+               agerr (AGERR, "Gstack overflow in graph parser\n"); exit(1);
+       }
+#endif
        G = Gstack[GSP++] = g;
 }
+       
 
 static Agraph_t *pop_subg(void)
 {