Fixed bug that left a dangling pointer after clearing the ifalias
property. This happened when calling 'rtnl_link_get_ifalias(link, NULL)'
on a link that has already an ifalias set.
This can cause a crash and/or a double-free.
Error found by coverity.
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
void rtnl_link_set_ifalias(struct rtnl_link *link, const char *alias)
{
free(link->l_ifalias);
- link->ce_mask &= ~LINK_ATTR_IFALIAS;
if (alias) {
link->l_ifalias = strdup(alias);
link->ce_mask |= LINK_ATTR_IFALIAS;
+ } else {
+ link->l_ifalias = NULL;
+ link->ce_mask &= ~LINK_ATTR_IFALIAS;
}
}