[gtk/wip/otte/json: 13/14] jsonparser: Don't treat \0 as eof
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/json: 13/14] jsonparser: Don't treat \0 as eof
- Date: Sun, 5 Dec 2021 17:21:53 +0000 (UTC)
commit 23bb8ee410bab280c118636951057956ed9e9157
Author: Benjamin Otte <otte redhat com>
Date: Sun Dec 5 18:06:02 2021 +0100
jsonparser: Don't treat \0 as eof
Instead, treat it as regular part of the data and emit errors when we
encounter it.
gtk/json/gtkjsonparser.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gtk/json/gtkjsonparser.c b/gtk/json/gtkjsonparser.c
index 2f0ba96ed9..dd8d4e95f4 100644
--- a/gtk/json/gtkjsonparser.c
+++ b/gtk/json/gtkjsonparser.c
@@ -393,7 +393,7 @@ gtk_json_parser_schema_error (GtkJsonParser *self,
static gboolean
gtk_json_parser_is_eof (GtkJsonParser *self)
{
- return self->reader >= self->end || *self->reader == '\0';
+ return self->reader >= self->end;
}
static gsize
@@ -900,6 +900,8 @@ gtk_json_parser_parse_value (GtkJsonParser *self)
end++;
gtk_json_parser_syntax_error_at (self, self->block->value, end, "Numbers may not start with '%c'",
*self->block->value);
}
+ else if (*self->reader == 0)
+ gtk_json_parser_syntax_error (self, "Unexpected nul byte in document");
else
gtk_json_parser_syntax_error (self, "Expected a value");
return FALSE;
@@ -1067,10 +1069,10 @@ gtk_json_parser_next (GtkJsonParser *self)
if (gtk_json_parser_is_eof (self))
{
self->block->value = NULL;
- if (gtk_json_parser_remaining (self))
- {
- gtk_json_parser_syntax_error (self, "Unexpected nul byte in document");
- }
+ }
+ else if (*self->reader == 0)
+ {
+ gtk_json_parser_syntax_error (self, "Unexpected nul byte in document");
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]