BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
695 stars 264 forks source link

Avoid reusing the EOF token (fixes BaseXdb/basex#2328) #2331

Closed GuntherRademacher closed 3 months ago

GuntherRademacher commented 3 months ago

RegexLexer was using a single static instance EOF_TOKEN whenever reaching the end of input. However the state of a Token comprises the next member, which RegexParser uses to set up a linked list of tokens. This could lead to EOF_TOKEN being linked to itself, creating an endless list, when RegexLexer.getNextToken was called again after the end had already been noticed.

Usually this does not happen, but the code in RegexParser.charRange does not consider EOF, which may lead to an extra token being acquired.

These changes remove RegexLexer.EOF_TOKEN, and add extra EOF-checking to RegexParser.charRange.