[json-glib] parser: Use the right length for parsing the stream contents
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib] parser: Use the right length for parsing the stream contents
- Date: Thu, 17 Apr 2014 14:32:47 +0000 (UTC)
commit e31683d2804916da23d1e48b80b124b37df1c8e6
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Apr 17 15:28:15 2014 +0100
parser: Use the right length for parsing the stream contents
The ByteArray we use to buffer the contents of a stream in order to
pass them to the parser may have a bigger length. We should use the
cursor position that we use to put a '\0' in the buffer instead. We
could also use -1, but this saves us a strlen() later on.
json-glib/json-parser.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index 16aee60..6b9cb1e 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -1238,7 +1238,7 @@ json_parser_load_from_stream (JsonParser *parser,
content->data[pos] = 0;
internal_error = NULL;
- retval = json_parser_load (parser, (const gchar *) content->data, content->len, &internal_error);
+ retval = json_parser_load (parser, (const gchar *) content->data, pos, &internal_error);
if (internal_error != NULL)
g_propagate_error (error, internal_error);
@@ -1388,7 +1388,7 @@ json_parser_load_from_stream_finish (JsonParser *parser,
data->content->data[data->pos] = 0;
internal_error = NULL;
- res = json_parser_load (parser, (const gchar *) data->content->data, data->content->len, &internal_error);
+ res = json_parser_load (parser, (const gchar *) data->content->data, data->pos, &internal_error);
if (internal_error != NULL)
g_propagate_error (error, internal_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]