From 08a3fd8b654b2cf2be0344419eec887b126b5ce0 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 14 Apr 2022 13:20:12 +0100 Subject: [PATCH] redfish: Fix a memory leak when calling ->setup() more than once --- plugins/redfish/fu-redfish-backend.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/redfish/fu-redfish-backend.c b/plugins/redfish/fu-redfish-backend.c index 417e731bc..f724b358c 100644 --- a/plugins/redfish/fu-redfish-backend.c +++ b/plugins/redfish/fu-redfish-backend.c @@ -284,6 +284,17 @@ fu_redfish_backend_coldplug(FuBackend *backend, GError **error) 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 fu_redfish_backend_setup(FuBackend *backend, GError **error) { @@ -339,7 +350,7 @@ fu_redfish_backend_setup(FuBackend *backend, GError **error) "no @odata.id string"); return FALSE; } - self->update_uri_path = g_strdup(data_id); + fu_redfish_backend_set_update_uri_path(self, data_id); return TRUE; }