diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2014-04-17 15:28:15 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2014-04-17 15:32:06 +0100 |
commit | e31683d2804916da23d1e48b80b124b37df1c8e6 (patch) | |
tree | 88555520c95ff842b6e207011278280805fd6c02 /json-glib/json-parser.c | |
parent | 289e75bd35c5ee268269f09c9e2db90602994fc1 (diff) | |
download | json-glib-e31683d2804916da23d1e48b80b124b37df1c8e6.tar.gz |
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.
Diffstat (limited to 'json-glib/json-parser.c')
-rw-r--r-- | 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); |