qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>

authored by

Liam Merwick and committed by
Markus Armbruster
19e8ff48 ad85b0b4

+1 -1
+1 -1
qobject/json-lexer.c
··· 266 266 { 267 267 uint8_t next; 268 268 269 - assert(lexer->state <= ARRAY_SIZE(json_lexer)); 269 + assert(lexer->state < ARRAY_SIZE(json_lexer)); 270 270 next = json_lexer[lexer->state][(uint8_t)ch]; 271 271 *char_consumed = !flush && !(next & LOOKAHEAD); 272 272 return next & ~LOOKAHEAD;