From f508a6a0d6ec0ea5563cf11e44a89f28a012bc10 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 18 Mar 2005 20:57:19 +0000 Subject: [PATCH] (glr-regr2a.y): Try to dump core immediately if a data overrun has occurred; this may help us track down what may be a spurious failure on MacOS. --- tests/glr-regression.at | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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'; } -- 2.47.2