From f592b067229990a8dbd71743ffc0eb0bc54a2ac2 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 24 Jul 2017 10:55:03 +0100 Subject: [PATCH] dell: Fix the last of the memory leaks in the self tests Fixes: https://github.com/hughsie/fwupd/issues/158 --- plugins/dell/fu-self-test.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/dell/fu-self-test.c b/plugins/dell/fu-self-test.c index 01b557f78..367497c95 100644 --- a/plugins/dell/fu-self-test.c +++ b/plugins/dell/fu-self-test.c @@ -40,7 +40,7 @@ static void _plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) { FuDevice **dev = (FuDevice **) user_data; - *dev = g_object_ref (device); + g_set_object (dev, device); } static void @@ -117,6 +117,7 @@ fu_plugin_dell_tpm_func (void) /* cleanup */ fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device); + g_clear_object (&device); /* inject fake data: * - that hasflashes @@ -148,6 +149,7 @@ fu_plugin_dell_tpm_func (void) /* cleanup */ fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device); + g_clear_object (&device); /* inject fake data: * - that has flashes @@ -186,6 +188,7 @@ fu_plugin_dell_tpm_func (void) /* cleanup */ fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device); + g_clear_object (&device); /* inject fake data: * - that has 1 flash left @@ -227,6 +230,7 @@ fu_plugin_dell_tpm_func (void) /* cleanup */ fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device); + g_clear_object (&device); } static void @@ -307,7 +311,7 @@ fu_plugin_dell_dock_func (void) fu_plugin_dell_device_added_cb (NULL, NULL, plugin); g_assert (device != NULL); - device = NULL; + g_clear_object (&device); g_free (buf.record); fu_plugin_dell_device_removed_cb (NULL, NULL, plugin); @@ -344,7 +348,7 @@ fu_plugin_dell_dock_func (void) fu_plugin_dell_device_added_cb (NULL, NULL, plugin); g_assert (device != NULL); - device = NULL; + g_clear_object (&device); g_free (buf.record); fu_plugin_dell_device_removed_cb (NULL, NULL, plugin); @@ -379,7 +383,7 @@ fu_plugin_dell_dock_func (void) fu_plugin_dell_device_added_cb (NULL, NULL, plugin); g_assert (device != NULL); - device = NULL; + g_clear_object (&device); g_free (buf.record); fu_plugin_dell_device_removed_cb (NULL, NULL, plugin); @@ -414,7 +418,7 @@ fu_plugin_dell_dock_func (void) fu_plugin_dell_device_added_cb (NULL, NULL, plugin); g_assert (device != NULL); - device = NULL; + g_clear_object (&device); g_free (buf.record); fu_plugin_dell_device_removed_cb (NULL, NULL, plugin);