Commit ce2f780b authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

Revert "Revert "Fix array termination and size calculation""

This reverts commit cfda820e.
parent 832f16f9
......@@ -794,7 +794,11 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state,
if (sequence_cache->item_cache->type_tag == GI_TYPE_TAG_UINT8 &&
PYGLIB_PyBytes_Check (py_arg)) {
memcpy(array_->data, PYGLIB_PyBytes_AsString (py_arg), length);
if (sequence_cache->is_zero_terminated) {
/* If array_ has been created with zero_termination, space for the
* terminator is properly allocated, so we're not off-by-one here. */
array_->data[length] = '\0';
}
goto array_success;
}
......
......@@ -266,6 +266,8 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
array_ = arg->v_pointer;
g_assert(array_ != NULL);
/* GArrays make it easier to iterate over arrays
* with different element sizes but requires that
* we allocate a GArray if the argument was a C array
......@@ -275,7 +277,11 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
if (seq_cache->fixed_size >= 0) {
len = seq_cache->fixed_size;
} else if (seq_cache->is_zero_terminated) {
len = g_strv_length ((gchar **)arg->v_pointer);
if(seq_cache->item_cache->type_tag == GI_TYPE_TAG_UINT8) {
len = strlen (arg->v_pointer);
} else {
len = g_strv_length ((gchar **)arg->v_pointer);
}
} else {
GIArgument *len_arg = state->args[seq_cache->len_arg_index];
len = len_arg->v_long;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment