From 5cea80f170a3b44836d65120208e34402192c884 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Thu, 16 Feb 1995 11:52:11 +0000 Subject: [PATCH] Always return null-terminated identifiers from yylex(). --- usr.sbin/config/lang.l | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index be6a24cefac9..d4052f394f13 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -35,6 +35,7 @@ */ #include +#include #include "y.tab.h" #include "config.h" @@ -117,7 +118,7 @@ WORD [A-Za-z_][-A-Za-z_]* if ((i = kw_lookup(yytext)) == -1) { - yylval.str = yytext; + yylval.str = strdup(yytext); tprintf("id(%s) ", yytext); return ID; } @@ -126,7 +127,7 @@ WORD [A-Za-z_][-A-Za-z_]* } \"[^"]+\" { yytext[strlen(yytext)-1] = '\0'; - yylval.str = yytext + 1; + yylval.str = strdup(yytext + 1); return ID; } 0[0-7]* {