Fix a crash when using fu_plugin_device_add_delay()

By removing the device from the hash table before we add it to the devices
array we could inadvertently drop the last object reference if the plugin is
not using the (optional) cache.

Just re-arrange things to fix https://github.com/hughsie/fwupd/issues/259
This commit is contained in:
Richard Hughes 2017-09-18 11:07:39 +01:00
parent daa341720f
commit 0dec274e56

View File

@ -372,8 +372,8 @@ static gboolean
fu_plugin_device_add_delay_cb (gpointer user_data) fu_plugin_device_add_delay_cb (gpointer user_data)
{ {
FuPluginHelper *helper = (FuPluginHelper *) user_data; FuPluginHelper *helper = (FuPluginHelper *) user_data;
g_hash_table_remove (helper->devices, helper->device);
fu_plugin_device_add (helper->plugin, helper->device); fu_plugin_device_add (helper->plugin, helper->device);
g_hash_table_remove (helper->devices, helper->device);
fu_plugin_helper_free (helper); fu_plugin_helper_free (helper);
return FALSE; return FALSE;
} }