Skip to content

Commit 1735f55

Browse files
committed
[core] fix GError leak
Change-Id: I581d34880a4a592a6f81c49c21e95c7fb0061db6
1 parent 2b4e6d3 commit 1735f55

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/common/module.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ liModule* li_module_load(liModules *mods, const gchar* name, GError **err) {
7474
mod->module = g_module_open(mod->path, G_MODULE_BIND_LAZY);
7575

7676
if (!mod->module) {
77+
/* remember original error if second try fails too */
7778
if (err) g_set_error(err, LI_MODULES_ERROR, 1, "%s", g_module_error());
7879
g_free(mod->path);
7980

@@ -86,6 +87,12 @@ liModule* li_module_load(liModules *mods, const gchar* name, GError **err) {
8687
g_slice_free(liModule, mod);
8788
return NULL;
8889
}
90+
91+
/* it worked out, clean error */
92+
if (err) {
93+
g_error_free(*err);
94+
*err = NULL;
95+
}
8996
}
9097

9198
/* temporary strings for mod_xyz_init and mod_xyz_free */

0 commit comments

Comments
 (0)