Fix a json parsing bug (#7490)

When parsing a lexeme, we use one less byte than it's intended to be for
comparing the current string.

This results in a success in cases like:
- true and truX
- false and falsX
- null and nulX
where X means an arbitrary character.

Fix this by the full intended length.
This commit is contained in:
Sungun Park
2024-01-11 12:47:11 -08:00
committed by GitHub
parent 44ff79ad34
commit 20ff230b92

View File

@@ -27,9 +27,7 @@ JsonType JsonishLexer::readIdentifier() noexcept {
consume();
}
const char* lexemeEnd = mCursor - 1;
size_t lexemeSize = lexemeEnd - lexemeStart;
size_t lexemeSize = mCursor - lexemeStart;
// Check what kind of keyword we got here.
if (strncmp("true", lexemeStart, lexemeSize) == 0) {