glr.c: initialize vector of bools

The CI, with CC='gcc-7 -fsanitize=undefined,address
-fno-omit-frame-pointer', reports:

    calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    ../../tests/calc.at:867: cat stderr
    --- expout	2019-09-05 20:30:37.887257545 +0000
    +++ /home/travis/build/bison-3.4.1.72-79a1-dirty/_build/tests/testsuite.dir/at-groups/438/stdout	2019-09-05 20:30:37.887257545 +0000
    @@ -1 +1,2 @@
     syntax error
    +calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    438. calc.at:867: 438. Calculator glr.cc  (calc.at:867): FAILED (calc.at:867)

The problem is that yylookaheadNeeds is not initialized in
yyinitStateSet, and when it is copied, the value is not 0 or 1.

* data/skeletons/glr.c (yylookaheadNeeds): Initialize yylookaheadNeeds.
This commit is contained in:
Akim Demaille
2019-09-06 07:37:26 +02:00
parent 628012d830
commit 29c75ef27f

View File

@@ -1094,17 +1094,20 @@ yyinitStateSet (yyGLRStateSet* yyset)
{ {
yyset->yysize = 1; yyset->yysize = 1;
yyset->yycapacity = 16; yyset->yycapacity = 16;
yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]); yyset->yystates
= (yyGLRState**) YYMALLOC (yyset->yycapacity * sizeof yyset->yystates[0]);
if (! yyset->yystates) if (! yyset->yystates)
return yyfalse; return yyfalse;
yyset->yystates[0] = YY_NULLPTR; yyset->yystates[0] = YY_NULLPTR;
yyset->yylookaheadNeeds = yyset->yylookaheadNeeds
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]); = (yybool*) YYMALLOC (yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
if (! yyset->yylookaheadNeeds) if (! yyset->yylookaheadNeeds)
{ {
YYFREE (yyset->yystates); YYFREE (yyset->yystates);
return yyfalse; return yyfalse;
} }
memset (yyset->yylookaheadNeeds,
0, yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
return yytrue; return yytrue;
} }