• Martin Pitt's avatar
    Fix Python to C marshalling of GValue arrays · d7d28d71
    Martin Pitt authored
    For GValues we cannot just copy the GValue memory in
    _pygi_marshal_from_py_array(), as the from_py_cleanup() function clears and
    releases the GValue and with it its v_pointer. Use g_value_copy() to copy by
    value instead.
    
    This uncovered another bug in _pygi_marshal_cleanup_from_py_array(): It always
    assumed that C arrays contained pointers, but this is not the case for GValue
    arrays: these are actual struct arrays, not struct pointer arrays (cf. their
    construction in _pygi_marshal_from_py_array()). Check if an array contains
    pointers or values and compute the correct array item pointer for both cases.
    
    Also add a corresponding test case for marshalling GValue arrays from C back to
    Python, which works fine.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672065
    d7d28d71
pygi-marshal-cleanup.c 20 KB