From: ellson Date: Sun, 21 Sep 2008 02:10:38 +0000 (+0000) Subject: double size of graph stack and error on overflow X-Git-Tag: LAST_LIBGRAPH~32^2~3356 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6230ba288ea713eeb111a569c8dd43c77f65c0ca;p=graphviz double size of graph stack and error on overflow --- diff --git a/lib/graph/parser.y b/lib/graph/parser.y index 4bb215e7b..b5d3db453 100644 --- a/lib/graph/parser.y +++ b/lib/graph/parser.y @@ -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) {