aboutsummaryrefslogtreecommitdiff
path: root/libbutl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-05 09:12:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-05 09:12:25 +0200
commit81ec829b96a01ef08b9fa6191c603c2a4d856c2c (patch)
tree9bf189ebf352347325805a2fbe21514ac8b6c2bc /libbutl
parentd9dd84487bda8303590d5b30987f1d76b93867ba (diff)
Fix bug in pdjson.c
Diffstat (limited to 'libbutl')
-rw-r--r--libbutl/json/pdjson.c9
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;