• Martin Pitt's avatar
    Fix memory handling of caller-allocated boxed types · 64bcca2d
    Martin Pitt authored
    _pygi_marshal_to_py_interface_struct() and other places treat subtypes of
    G_TYPE_BOXED as boxed values and wrap them with _pygi_boxed_new(). Fix
    _caller_alloc() and _cleanup_caller_allocates() to consider G_TYPE_BOXED
    subtypes as well and use the slice allocator instead of malloc()'ing a struct.
    This avoids trying to free an malloc'ed struct with g_slice_free() and properly
    cleans up the boxed values.
    
    The leak was produced with:
    
    G_SLICE=debug-blocks PYTHONPATH=. valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no \
      python3 -c 'from gi.repository import Gtk; b=Gtk.TextBuffer(); (s,e) = b.get_bounds()'
    64bcca2d
pygi-marshal-cleanup.c 21.5 KB