From b0722cf75ec701c746ce38ccf1a34d833fe13aed Mon Sep 17 00:00:00 2001 From: Jintao Lin Date: Tue, 6 Dec 2022 00:37:04 +0000 Subject: [PATCH] dbus: Fix a memory leak on error path in CreateInterface method Fix a potential memory leak in CreateInterface method. Fixes: 0ba266d86c90 ("dbus: Add virtual interface create/remove logic to be inline with ctrl_iface") Signed-off-by: Jintao Lin --- wpa_supplicant/dbus/dbus_new_handlers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 9a0f8c157..d2c78ecfa 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -817,12 +817,14 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, wpa_dbus_dict_entry_clear(&entry); } else if (os_strcmp(entry.key, "Type") == 0 && entry.type == DBUS_TYPE_STRING) { - if (os_strcmp(entry.str_value, "sta") == 0) + if (os_strcmp(entry.str_value, "sta") == 0) { if_type = WPA_IF_STATION; - else if (os_strcmp(entry.str_value, "ap") == 0) + } else if (os_strcmp(entry.str_value, "ap") == 0) { if_type = WPA_IF_AP_BSS; - else + } else { + wpa_dbus_dict_entry_clear(&entry); goto error; + } wpa_dbus_dict_entry_clear(&entry); } else { wpa_dbus_dict_entry_clear(&entry);