From d95cf75bf0aa415b5cb09778eb1cf800691ac186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 18 Oct 2022 11:01:11 +0400 Subject: [PATCH] gio/module: ignore module leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A module must exist forever after it is loaded. If it's not referenced anywhere, as with some gio tests, ASAN will report direct leaks. Silence those. Signed-off-by: Marc-André Lureau --- gio/giomodule.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gio/giomodule.c b/gio/giomodule.c index d8ed9801e..1c4b654c0 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -579,7 +579,11 @@ g_io_modules_scan_all_in_directory_with_scope (const char *dirname, { /* Try to load and init types */ if (g_type_module_use (G_TYPE_MODULE (module))) - g_type_module_unuse (G_TYPE_MODULE (module)); /* Unload */ + { + g_type_module_unuse (G_TYPE_MODULE (module)); /* Unload */ + /* module must remain alive, because the type system keeps weak refs */ + g_ignore_leak (module); + } else { g_printerr ("Failed to load module: %s\n", path);