Fix an array overflow which led to an assertion crash.

Reported by:	miwi
Obtained from:	http://bugzilla.openedhand.com/show_bug.cgi?id=1203
This commit is contained in:
Joe Marcus Clarke 2008-12-26 18:38:37 +00:00
parent da8d6be057
commit cbc3a858c8
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=224810
2 changed files with 22 additions and 0 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= json-glib
PORTVERSION= 0.6.2
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://folks.o-hand.com/~ebassi/sources/

View File

@ -0,0 +1,21 @@
diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c
index 15e9ed5..eeb571c 100644
--- json-glib/json-gobject.c
+++ 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++)
{
@@ -201,6 +201,7 @@ json_deserialize_pspec (GValue *value,
if (json_node_get_string (val) != NULL);
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);