diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2010-05-22 13:09:48 +0200 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-05-22 13:14:48 +0200 |
commit | ab1aaff108d23aabd28c3634edfb67236eb55460 (patch) | |
tree | ae71c7c545b1ce3b4dd80bba564669a85e96b25e /gi/pygi-invoke.c | |
parent | e928ea9b1df9d87314ff8e93479530e26be9bd87 (diff) | |
download | pygobject-ab1aaff108d23aabd28c3634edfb67236eb55460.tar.gz |
fix NULL array unit tests and fix crasher when sending None as an array
* Unit tests were wrong given the annotation for test_array_int_null_in and
test_array_int_null_out:
/**
* test_array_int_null_in:
* @arr: (array length=len) (allow-none):
* @len: length
*/
-- and --
/**
* test_array_int_null_out:
* @arr: (out) (array length=len) (allow-none):
* @len: (out) : length
*/
The (array length=len) annotation meant we don't pass in or
receive the len argument as this is handled under the hood
(Python's representation of an array, the list type, encapsulates
the length inside the type)
* Fixing up the tests revealed a latent crasher bug when passing None to an
interface that accepts an array. The fix was to check for NULL and set
the length argument to 0 when invoking the bound method.
https://bugzilla.gnome.org/show_bug.cgi?id=619235
Diffstat (limited to 'gi/pygi-invoke.c')
-rw-r--r-- | gi/pygi-invoke.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index 0373a0d8..11c6f236 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -501,8 +501,12 @@ _prepare_invocation_state (struct invocation_state *state, if (state->is_method) length_arg_pos--; // length_arg_pos refers to C args if (length_arg_pos >= 0) { + int len = 0; /* Set the auxiliary argument holding the length. */ - state->args[length_arg_pos]->v_size = array->len; + if (array) + len = array->len; + + state->args[length_arg_pos]->v_size = len; } /* Get rid of the GArray. */ |