From 20ff230b92e62deb4df36da1109818eb6c7e4a3d Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Thu, 11 Jan 2024 12:47:11 -0800 Subject: [PATCH] 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. --- tools/matc/src/matc/JsonishLexer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/matc/src/matc/JsonishLexer.cpp b/tools/matc/src/matc/JsonishLexer.cpp index 3cca02e560..2173693c0a 100644 --- a/tools/matc/src/matc/JsonishLexer.cpp +++ b/tools/matc/src/matc/JsonishLexer.cpp @@ -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) {