mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user