Commit d32b410a authored by Martin Pitt's avatar Martin Pitt
Browse files

Fix leaking inout C arrays

g_*_info_invoke() changes the original state->in_args and state->args C arrays
to the output values for (inout) arguments, thus losing the pointer to the
originally allocated array. Remember that in state->args_data, so that we can
free it in _pygi_marshal_cleanup_from_py_array().

Reproduced by test_gi.TestArray.test_array_fixed_inout test case.
parent e4098cbc
......@@ -101,6 +101,12 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
arg_cache->direction == PYGI_DIRECTION_FROM_PYTHON &&
state->args[i]->v_pointer != NULL)
cleanup_func (state, arg_cache, state->args[i]->v_pointer, TRUE);
if (cleanup_func &&
arg_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL &&
state->args_data[i] != NULL) {
cleanup_func (state, arg_cache, state->args_data[i], TRUE);
}
}
}
......
......@@ -1104,6 +1104,10 @@ array_success:
if (sequence_cache->array_type == GI_ARRAY_TYPE_C) {
arg->v_pointer = array_->data;
g_array_free (array_, FALSE);
/* remember the originally allocated array in args_data, as args and
* in_args get changed for (inout) arguments */
if (arg_cache->transfer == GI_TRANSFER_NOTHING)
state->args_data[arg_cache->c_arg_index] = arg->v_pointer;
} else {
arg->v_pointer = array_;
}
......
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