[comp.bugs.4bsd] "awk" drops core on many syntax errors

guy%gorodish@Sun.COM (Guy Harris) (01/10/87)

Index:	bin/awk/awk.g.y 4.3BSD

Description:
	In a number of cases, "awk" will drop core when it encounters
	a syntax error.  If "awk"s standard error is redirected to a
	file, it may not even print the error messages.
Repeat-By:
	Run the following command:

		awk '{ ng[] = ; goop = 1; }' </dev/null

	and watch it drop core.
Fix:
*** /arch/4.3/usr/src/bin/awk/awk.g.y	Sun Feb 27 14:24:47 1983
--- ./awk.g.y	Fri Jan  9 21:01:29 1987
***************
*** 235,241 ****
  		{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
  	| expr	{ PUTS("expr"); $$ = exptostat($1); }
  	|		{ PUTS("null simple statement"); $$ = (hack)nullstat; }
! 	| error		{ yyclearin; yyerror("illegal statement"); }
  	;
  
  statement:
--- 235,241 ----
  		{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
  	| expr	{ PUTS("expr"); $$ = exptostat($1); }
  	|		{ PUTS("null simple statement"); $$ = (hack)nullstat; }
! 	| error		{ yyclearin; yyerror("illegal statement"); $$ = (int)0; }
  	;
  
  statement:

guy%gorodish@Sun.COM (Guy Harris) (01/10/87)

There was a slight error in the previous fix, due to the fact that the work
was done on the S5R2 "awk", and the fix wasn't properly retrofitted;
unfortunately, I couldn't convince "vnews" to cancel the original using NNTP.

Index:	bin/awk/awk.g.y 4.3BSD

Description:
	In a number of cases, "awk" will drop core when it encounters
	a syntax error.  If "awk"s standard error is redirected to a
	file, it may not even print the error messages.
Repeat-By:
	Run the following command:

		awk '{ ng[] = ; goop = 1; }' </dev/null

	and watch it drop core.
Fix:
*** /arch/4.3/usr/src/bin/awk/awk.g.y	Sun Feb 27 14:24:47 1983
--- ./awk.g.y	Fri Jan  9 21:01:29 1987
***************
*** 235,241 ****
  		{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
  	| expr	{ PUTS("expr"); $$ = exptostat($1); }
  	|		{ PUTS("null simple statement"); $$ = (hack)nullstat; }
! 	| error		{ yyclearin; yyerror("illegal statement"); }
  	;
  
  statement:
--- 235,241 ----
  		{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
  	| expr	{ PUTS("expr"); $$ = exptostat($1); }
  	|		{ PUTS("null simple statement"); $$ = (hack)nullstat; }
! 	| error		{ yyclearin; yyerror("illegal statement"); $$ = (hack)nullstat; }
  	;
  
  statement: