redfish: Fix a memory leak when calling ->setup() more than once

This commit is contained in:
Richard Hughes 2022-04-14 13:20:12 +01:00
parent a8497ad5c2
commit 08a3fd8b65

View File

@ -284,6 +284,17 @@ fu_redfish_backend_coldplug(FuBackend *backend, GError **error)
return TRUE; return TRUE;
} }
static void
fu_redfish_backend_set_update_uri_path(FuRedfishBackend *self, const gchar *update_uri_path)
{
/* not changed */
if (g_strcmp0(self->update_uri_path, update_uri_path) == 0)
return;
g_free(self->update_uri_path);
self->update_uri_path = g_strdup(update_uri_path);
}
static gboolean static gboolean
fu_redfish_backend_setup(FuBackend *backend, GError **error) fu_redfish_backend_setup(FuBackend *backend, GError **error)
{ {
@ -339,7 +350,7 @@ fu_redfish_backend_setup(FuBackend *backend, GError **error)
"no @odata.id string"); "no @odata.id string");
return FALSE; return FALSE;
} }
self->update_uri_path = g_strdup(data_id); fu_redfish_backend_set_update_uri_path(self, data_id);
return TRUE; return TRUE;
} }