[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS: cvs.openbsd.org: src

Module name:	src
Changes by:	henning_(_at_)_cvs_(_dot_)_openbsd_(_dot_)_org	2004/03/06 14:41:44

Modified files:
	usr.sbin/bgpd  : parse.y 

Log message:
plug a memory leak in the lexer.
the issue is this code fragement from yylex():
.		token = lookup(buf);
.		yylval.v.string = strdup(buf);
.		if (yylval.v.string == NULL)
.			fatal("yylex: strdup");
.		return (token);
lookup() tries to match buf against a list of keywords, and returns the
associated token if it has a match, or the token STRING otherwise.
STRING is the only token that needs (and free()s) yylval.v.string. however,
we assigned memory for it with the strdup in yylex for each and every token.
the fix is obviously only setting yylval.v.string when lookup() returns STRING.
Patrick Latifi noticed that something was leaking with token handling,
analysis and fix by me.
ok deraadt@