summaryrefslogtreecommitdiff
path: root/json-glib/json-gobject.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2008-11-03 15:51:21 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2008-11-03 15:56:39 +0000
commitcf4c7360c69c0fe7587ec2456cd10839e1d0c1d6 (patch)
treedbd09925cd9adb2f940fcb73451346a6b5808769 /json-glib/json-gobject.c
parent9b94bc7f99063f45a2725861369f36b53ec3d440 (diff)
downloadjson-glib-cf4c7360c69c0fe7587ec2456cd10839e1d0c1d6.tar.gz
Correctly terminate a string array
When converting from a JsonArray of strings to a GStrv we need to add a NULL at the end of the GPtrArray we use to perform the conversion. This two lines patch fixes the issue. See bug 1203. Patch by: Kouhei Sutou <kou@cozmixng.org> Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Diffstat (limited to 'json-glib/json-gobject.c')
-rw-r--r--json-glib/json-gobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c
index 15e9ed5..5224250 100644
--- a/json-glib/json-gobject.c
+++ b/json-glib/json-gobject.c
@@ -189,7 +189,7 @@ json_deserialize_pspec (GValue *value,
{
JsonArray *array = json_node_get_array (node);
guint i, array_len = json_array_get_length (array);
- GPtrArray *str_array = g_ptr_array_sized_new (array_len);
+ GPtrArray *str_array = g_ptr_array_sized_new (array_len + 1);
for (i = 0; i < array_len; i++)
{
@@ -202,6 +202,8 @@ json_deserialize_pspec (GValue *value,
g_ptr_array_add (str_array, (gpointer) json_node_get_string (val));
}
+ g_ptr_array_add (str_array, NULL);
+
g_value_set_boxed (value, str_array->pdata);
g_ptr_array_free (str_array, TRUE);