From 1735f5524f7bd5cce6f746c766ee23f02231897c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 6 Feb 2024 14:27:17 +0100 Subject: [PATCH] [core] fix GError leak Change-Id: I581d34880a4a592a6f81c49c21e95c7fb0061db6 --- src/common/module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/module.c b/src/common/module.c index ee8f901e..e270d212 100644 --- a/src/common/module.c +++ b/src/common/module.c @@ -74,6 +74,7 @@ liModule* li_module_load(liModules *mods, const gchar* name, GError **err) { mod->module = g_module_open(mod->path, G_MODULE_BIND_LAZY); if (!mod->module) { + /* remember original error if second try fails too */ if (err) g_set_error(err, LI_MODULES_ERROR, 1, "%s", g_module_error()); g_free(mod->path); @@ -86,6 +87,12 @@ liModule* li_module_load(liModules *mods, const gchar* name, GError **err) { g_slice_free(liModule, mod); return NULL; } + + /* it worked out, clean error */ + if (err) { + g_error_free(*err); + *err = NULL; + } } /* temporary strings for mod_xyz_init and mod_xyz_free */