On Wed, 31 Mar 2010, tys lefering wrote:

> Using bison with wrapped malloc/free and testing
> it doing intentionally unusual things with the
> possible settings in bison generated yacc parser
> did not found a segfault situation but came across:
> 
> /* set initial size of parser stack */
> #define YYINITDEPTH 0

The manual says YYINITDEPTH must be a positive integer.

> it is easy to fix in yyparse():
> 
>   yystacksize = YYINITDEPTH;
>   if (!yystacksize) { yystacksize = 1; }
>   YYDPRINTF ((stderr, "Starting parse\n"));

This change is not sufficient to handle YYINITDEPTH=0 because YYINITDEPTH 
is used as the size of several arrays.  At most, I could see throwing a 
#error if YYINITDEPTH=0, but not in 2.4.3, where we're still supposedly 
supporting K&R.


Reply via email to