diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-10-05 09:12:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-10-05 09:12:25 +0200 |
commit | 81ec829b96a01ef08b9fa6191c603c2a4d856c2c (patch) | |
tree | 9bf189ebf352347325805a2fbe21514ac8b6c2bc | |
parent | d9dd84487bda8303590d5b30987f1d76b93867ba (diff) |
Fix bug in pdjson.c
-rw-r--r-- | libbutl/json/pdjson.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libbutl/json/pdjson.c b/libbutl/json/pdjson.c index 279d169..0db9a20 100644 --- a/libbutl/json/pdjson.c +++ b/libbutl/json/pdjson.c @@ -472,11 +472,14 @@ read_utf8(json_stream* json, int next_char) int i; for (i = 1; i < count; ++i) { - if ((buffer[i] = json->source.get(&json->source)) != EOF) - json->lineadj++; + if ((next_char = json->source.get(&json->source)) == EOF) + break; + + buffer[i] = next_char; + json->lineadj++; } - if (!is_legal_utf8((unsigned char*) buffer, count)) + if (i != count || !is_legal_utf8((unsigned char*) buffer, count)) { json_error(json, "%s", "invalid UTF-8 text"); return -1; |