diff --git a/tests/glr-regression.at b/tests/glr-regression.at index e98a5156..32a39f25 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -127,6 +127,7 @@ AT_DATA_GRAMMAR([glr-regr2a.y], #include #include + #include #include int yylex (void); void yyerror (char const *); @@ -155,11 +156,10 @@ var_list: { $$ = $1; } | var ',' var_list { - char buffer[50]; - strcpy (buffer, $1); - strcat (buffer, ","); - strcat (buffer, $3); - $$ = strdup (buffer); + $$ = malloc (strlen ($1) + 1 + strlen ($3) + 1); + strcpy ($$, $1); + strcat ($$, ","); + strcat ($$, $3); } ; @@ -182,8 +182,12 @@ yylex (void) default: break; } - fscanf (yyin, "%s", buf); - yylval = strdup (buf); + if (fscanf (yyin, "%49s", buf) != 1) + abort (); + if (sizeof buf - 1 <= strlen (buf)) + abort (); + yylval = malloc (strlen (buf) + 1); + strcpy (yylval, buf); return 'V'; }