diff --git a/json_tokener.c b/json_tokener.c index 48d4109..94d43b4 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -762,7 +762,14 @@ struct fjson_object *fjson_tokener_parse_ex(struct fjson_tokener *tok, const cha printbuf_memappend_fast(tok->pb, case_start, case_len); // Check for -Infinity - if (tok->pb->buf[0] == '-' && case_len == 1 && (c == 'i' || c == 'I')) { + // Use bpos (the total number of bytes buffered so far) + // rather than case_len (only what this call appended), so + // that "-" and "Infinity" split across incremental calls + // are still recognized. Reset st_pos, which may carry a + // stale value from a previously parsed token. + if (tok->pb->bpos == 1 && tok->pb->buf[0] == '-' && + (c == 'i' || c == 'I')) { + tok->st_pos = 0; state = fjson_tokener_state_inf; goto redo_char; }