Merge pull request #5 from vegard/lexer-fix-for-bentley

Prevent lexer from reading beyond the end of the buffer
This commit is contained in:
Anthony J. Bentley
2012-12-01 22:46:21 -08:00

View File

@@ -392,6 +392,15 @@ scanagain:
hash = 0; hash = 0;
s = pLexBuffer; s = pLexBuffer;
while (yyleng < nLexMaxLeng) { while (yyleng < nLexMaxLeng) {
/* XXX: Kludge warning! The dereference of s below
* may go beyond the end of the buffer. We use the
* following test to stop that from happening,
* without really understanding what the rest of
* the code is doing. This may not be the correct
* fix! */
if (!*s)
break;
yyleng += 1; yyleng += 1;
hash = ((hash << 1) + (toupper(*s))) % LEXHASHSIZE; hash = ((hash << 1) + (toupper(*s))) % LEXHASHSIZE;
s += 1; s += 1;