9d1c44be21dc2fc8f04852b8c51d9ea145bace98
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 0373a0d..11c6f23 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. */
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 8fd1e06..48f6644 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -57,7 +57,7 @@ class TestNullableArgs(unittest.TestCase):
         Everything.test_glist_null_in(None)
 
     def test_in_nullable_array(self):
-        Everything.test_array_int_null_in(None, -1)
+        Everything.test_array_int_null_in(None)
 
     def test_in_nullable_string(self):
         Everything.test_utf8_null_in(None)
@@ -70,7 +70,7 @@ class TestNullableArgs(unittest.TestCase):
         self.assertEqual([], Everything.test_glist_null_out())
 
     def test_out_nullable_array(self):
-        self.assertEqual((None, 0), Everything.test_array_int_null_out())
+        self.assertEqual(None, Everything.test_array_int_null_out())
 
     def test_out_nullable_string(self):
         self.assertEqual(None, Everything.test_utf8_null_out())
