dell: Fix the last of the memory leaks in the self tests

Fixes: https://github.com/hughsie/fwupd/issues/158
This commit is contained in:
Richard Hughes 2017-07-24 10:55:03 +01:00
parent 4bfcae2921
commit f592b06722

View File

@ -40,7 +40,7 @@ static void
_plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) _plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data)
{ {
FuDevice **dev = (FuDevice **) user_data; FuDevice **dev = (FuDevice **) user_data;
*dev = g_object_ref (device); g_set_object (dev, device);
} }
static void static void
@ -117,6 +117,7 @@ fu_plugin_dell_tpm_func (void)
/* cleanup */ /* cleanup */
fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device_alt);
fu_plugin_device_remove (plugin, device); fu_plugin_device_remove (plugin, device);
g_clear_object (&device);
/* inject fake data: /* inject fake data:
* - that hasflashes * - that hasflashes
@ -148,6 +149,7 @@ fu_plugin_dell_tpm_func (void)
/* cleanup */ /* cleanup */
fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device_alt);
fu_plugin_device_remove (plugin, device); fu_plugin_device_remove (plugin, device);
g_clear_object (&device);
/* inject fake data: /* inject fake data:
* - that has flashes * - that has flashes
@ -186,6 +188,7 @@ fu_plugin_dell_tpm_func (void)
/* cleanup */ /* cleanup */
fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device_alt);
fu_plugin_device_remove (plugin, device); fu_plugin_device_remove (plugin, device);
g_clear_object (&device);
/* inject fake data: /* inject fake data:
* - that has 1 flash left * - that has 1 flash left
@ -227,6 +230,7 @@ fu_plugin_dell_tpm_func (void)
/* cleanup */ /* cleanup */
fu_plugin_device_remove (plugin, device_alt); fu_plugin_device_remove (plugin, device_alt);
fu_plugin_device_remove (plugin, device); fu_plugin_device_remove (plugin, device);
g_clear_object (&device);
} }
static void static void
@ -307,7 +311,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_device_added_cb (NULL, NULL, fu_plugin_dell_device_added_cb (NULL, NULL,
plugin); plugin);
g_assert (device != NULL); g_assert (device != NULL);
device = NULL; g_clear_object (&device);
g_free (buf.record); g_free (buf.record);
fu_plugin_dell_device_removed_cb (NULL, NULL, fu_plugin_dell_device_removed_cb (NULL, NULL,
plugin); plugin);
@ -344,7 +348,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_device_added_cb (NULL, NULL, fu_plugin_dell_device_added_cb (NULL, NULL,
plugin); plugin);
g_assert (device != NULL); g_assert (device != NULL);
device = NULL; g_clear_object (&device);
g_free (buf.record); g_free (buf.record);
fu_plugin_dell_device_removed_cb (NULL, NULL, fu_plugin_dell_device_removed_cb (NULL, NULL,
plugin); plugin);
@ -379,7 +383,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_device_added_cb (NULL, NULL, fu_plugin_dell_device_added_cb (NULL, NULL,
plugin); plugin);
g_assert (device != NULL); g_assert (device != NULL);
device = NULL; g_clear_object (&device);
g_free (buf.record); g_free (buf.record);
fu_plugin_dell_device_removed_cb (NULL, NULL, fu_plugin_dell_device_removed_cb (NULL, NULL,
plugin); plugin);
@ -414,7 +418,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_device_added_cb (NULL, NULL, fu_plugin_dell_device_added_cb (NULL, NULL,
plugin); plugin);
g_assert (device != NULL); g_assert (device != NULL);
device = NULL; g_clear_object (&device);
g_free (buf.record); g_free (buf.record);
fu_plugin_dell_device_removed_cb (NULL, NULL, fu_plugin_dell_device_removed_cb (NULL, NULL,
plugin); plugin);