C and AWK questions
Tom Portegys
pem1a at ihuxr.UUCP
Sat Aug 18 06:26:10 AEST 1984
On your awk/malloc problem:
We just got done finding a nasty bug in a lex program which
clobbered the malloc memory. It either gave memory faults or
looped. Turned out to be caused by an overflow of an array
called yytext, which holds the input characters being matched.
This array was compiled to hold 200 characters, yet an
expression we wanted to match could far exceed that. So lex
merrily proceeded to overflow the array and destroy the
malloc linkages. The bug would appear when an fprintf attempted
to get some memory from malloc. The answer was to either make the
array yytext bigger, or to change the way to match the expression.
We chose the latter. We were also very disappointed that lex
did not do any special checking on this overflow problem.
Tom Portegys, Grant Rose, Mark Young
Bell Labs, Naperville, Ill.
ihnp4!ihuxr!pem1a
More information about the Comp.lang.c
mailing list