Commit Graph

3 Commits

Author SHA1 Message Date
Marc-André Lureau
bb890b57d2 gobject/gsignalgroup: fix memory leaks on error
Spotted by ASAN during the tests:

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7ff0b4562077 in calloc (/lib64/libasan.so.8+0xba077)
    #1 0x7ff0b3e8b508 in g_malloc0 ../glib/gmem.c:155
    #2 0x7ff0b375052f in g_closure_new_simple ../gobject/gclosure.c:220
    #3 0x7ff0b375b422 in g_cclosure_new ../gobject/gclosure.c:976
    #4 0x7ff0b37d159e in g_signal_group_connect_full ../gobject/gsignalgroup.c:790
    #5 0x7ff0b37d159e in g_signal_group_connect ../gobject/gsignalgroup.c:886
    #6 0x4045d8 in test_signal_group_invalid ../gobject/tests/signalgroup.c:331
    #7 0x7ff0b3f369a5 in test_case_run ../glib/gtestutils.c:2930
    #8 0x7ff0b3f369a5 in g_test_run_suite_internal ../glib/gtestutils.c:3018
    #9 0x7ff0b3f364ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #10 0x7ff0b3f364ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #11 0x7ff0b3f37879 in g_test_run_suite ../glib/gtestutils.c:3112
    #12 0x7ff0b3f37995 in g_test_run ../glib/gtestutils.c:2231
    #13 0x40253c in main ../gobject/tests/signalgroup.c:664
    #14 0x7ff0b2de758f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f012addf077 in calloc (/lib64/libasan.so.8+0xba077)
    #1 0x7f012a708508 in g_malloc0 ../glib/gmem.c:155
    #2 0x7f0129fcd52f in g_closure_new_simple ../gobject/gclosure.c:220
    #3 0x7f0129fd8422 in g_cclosure_new ../gobject/gclosure.c:976
    #4 0x7f012a04e5ae in g_signal_group_connect_full ../gobject/gsignalgroup.c:791
    #5 0x7f012a04e5ae in g_signal_group_connect ../gobject/gsignalgroup.c:887
    #6 0x4043cc in test_signal_group_invalid ../gobject/tests/signalgroup.c:308
    #7 0x7f012a7b39a5 in test_case_run ../glib/gtestutils.c:2930
    #8 0x7f012a7b39a5 in g_test_run_suite_internal ../glib/gtestutils.c:3018
    #9 0x7f012a7b34ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #10 0x7f012a7b34ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #11 0x7f012a7b4879 in g_test_run_suite ../glib/gtestutils.c:3112
    #12 0x7f012a7b4995 in g_test_run ../glib/gtestutils.c:2231
    #13 0x40253c in main ../gobject/tests/signalgroup.c:664
    #14 0x7f012966458f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00
Jason Francis
2a842b1173 gobject: Add g_signal_group_connect_closure 2022-04-05 15:32:20 +01:00
Christian Hergert
dd43471f60 gobject: add GSignalGroup
Much like GBindingGroup, the GSignalGroup object allows you to connect many
signal connections for an object and connect/disconnect/block/unblock them
as a group.

This is useful when using many connections on an object to ensure that they
are properly removed when changing state or disposing a third-party
object.

This has been used for years in various GNOME projects and makes sense to
have upstream instead of multiple copies.
2022-02-01 17:09:14 -08:00