commit e344df432bdca72e47374637e2c9ac28d469ac61
parent 98623edd7d61e3859a18e7d094deb50496afb44b
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Mon, 11 Mar 2019 15:43:20 +0100
wiphy: Fix printing supported iftypes
dbus_iftype_to_string returns NULL for unknown iftypes, the strdup will
also return NULL and ret[i] will be assigned a NULL. As a result
the l_strjoinv will not print the known iftypes that might have come
after that and will the l_strfreev will leak the strduped strings.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/wiphy.c b/src/wiphy.c
@@ -310,10 +310,14 @@ static char **wiphy_get_supported_iftypes(struct wiphy *wiphy)
unsigned int j;
for (j = 0, i = 0; i < sizeof(wiphy->supported_iftypes) * 8; i++) {
+ const char *str;
+
if (!(wiphy->supported_iftypes & (1 << i)))
continue;
- ret[j++] = l_strdup(dbus_iftype_to_string(i + 1));
+ str = dbus_iftype_to_string(i + 1);
+ if (str)
+ ret[j++] = l_strdup(str);
}
return ret;