diff options
author | Liam Merwick <liam.merwick@oracle.com> | 2019-03-21 11:57:52 +0000 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2019-03-26 08:10:11 +0100 |
commit | 19e8ff485a25001f48d7cbfaed24663dae001df7 (patch) | |
tree | b81a520be650d1e8c0b04d420a1e4f4d001068f9 | |
parent | ad85b0b4c737d59bcdfba1e75b9a202e12fb5349 (diff) |
json: Fix off-by-one assert check in next_state()
The assert checking if the value of lexer->state in next_state(),
which is used as an index to the 'json_lexer' array, incorrectly
checks for an index value less than or equal to ARRAY_SIZE(json_lexer).
Fix assert so that it just checks for an index less than the array size.
Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
Message-Id: <1553169472-25325-1-git-send-email-liam.merwick@oracle.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r-- | qobject/json-lexer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index a7df2093aa..632320d72d 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -266,7 +266,7 @@ static inline uint8_t next_state(JSONLexer *lexer, char ch, bool flush, { uint8_t next; - assert(lexer->state <= ARRAY_SIZE(json_lexer)); + assert(lexer->state < ARRAY_SIZE(json_lexer)); next = json_lexer[lexer->state][(uint8_t)ch]; *char_consumed = !flush && !(next & LOOKAHEAD); return next & ~LOOKAHEAD; |