Fix memory leak when plugin init fails
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 18 Oct 2008 16:06:18 +0000 (18:06 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 18 Oct 2008 16:06:18 +0000 (18:06 +0200)
src/plugin.c

index cfbd906..153b7be 100644 (file)
@@ -47,8 +47,10 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc)
        plugin->handle = handle;
        plugin->desc = desc;
 
-       if (desc->init() < 0)
+       if (desc->init() < 0) {
+               g_free(plugin);
                return FALSE;
+       }
 
        plugins = g_slist_append(plugins, plugin);