]> git.proxmox.com Git - mirror_qemu.git/commitdiff
json: Fix off-by-one assert check in next_state()
authorLiam Merwick <liam.merwick@oracle.com>
Thu, 21 Mar 2019 11:57:52 +0000 (11:57 +0000)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 26 Mar 2019 07:10:11 +0000 (08:10 +0100)
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>
qobject/json-lexer.c

index a7df2093aa3059304450e09f9f81de2a4a1a8d01..632320d72d5de5950b3482f492a1e668f6d406c9 100644 (file)
@@ -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;