From: Neil H. <nh...@us...> - 2009-08-28 14:28:41
|
Update of /cvsroot/cscope/cscope/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25714/src Modified Files: crossref.c fscanner.l scanner.h Log Message: The lexer, if passed a file with a c extension that has only a '=' or ':' symbol in it, will trigger lexer rules that expect my_yytext to be set. Since no other rules have been triggered yet, my_yytext is NULL and a segfault occurs. To fix this we add a LEXERR token and return it if my_yytext is null. This causes the crossref generator to detect the lexer error and abort further processing of the file. Index: crossref.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/crossref.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** crossref.c 23 Jul 2006 20:59:20 -0000 1.14 --- crossref.c 28 Aug 2009 14:28:27 -0000 1.15 *************** *** 177,180 **** --- 177,181 ---- break; + case LEXERR: /* Lexer error, abort further parsing of this file */ case LEXEOF: /* end of file; last line may not have \n */ Index: fscanner.l =================================================================== RCS file: /cvsroot/cscope/cscope/src/fscanner.l,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** fscanner.l 7 Jan 2007 12:41:23 -0000 1.13 --- fscanner.l 28 Aug 2009 14:28:27 -0000 1.14 *************** *** 402,405 **** --- 402,407 ---- } = { /* if a global definition initializer */ + if (!my_yytext) + return(LEXERR); if (global == YES && ppdefine == NO && my_yytext[0] != '#') { initializerbraces = braces; *************** *** 410,413 **** --- 412,417 ---- } : { /* a if global structure field */ + if (!my_yytext) + return(LEXERR); if (global == YES && ppdefine == NO && my_yytext[0] != '#') { structfield = YES; Index: scanner.h =================================================================== RCS file: /cvsroot/cscope/cscope/src/scanner.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** scanner.h 31 Jan 2005 16:50:33 -0000 1.4 --- scanner.h 28 Aug 2009 14:28:27 -0000 1.5 *************** *** 61,67 **** /* other scanner token types */ ! #define LEXEOF 0 ! #define IDENT 1 ! #define NEWLINE 2 /* scanner.l global data */ --- 61,68 ---- /* other scanner token types */ ! #define LEXEOF 0 ! #define LEXERR 1 ! #define IDENT 2 ! #define NEWLINE 3 /* scanner.l global data */ |