From e31683d2804916da23d1e48b80b124b37df1c8e6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 17 Apr 2014 15:28:15 +0100 Subject: 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 file changed, 2 insertions(+), 2 deletions(-) (limited to 'json-glib/json-parser.c') 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); -- cgit v1.2.1