mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
BUG/MINOR: namespace: handle a possible strdup() failure
This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches.
This commit is contained in:
parent
1f63a53955
commit
abee546850
@ -89,13 +89,23 @@ struct netns_entry* netns_store_insert(const char *ns_name)
|
||||
|
||||
entry = calloc(1, sizeof(*entry));
|
||||
if (!entry)
|
||||
goto out;
|
||||
goto err_close_fd;
|
||||
entry->fd = fd;
|
||||
entry->node.key = strdup(ns_name);
|
||||
if (!entry->node.key)
|
||||
goto err_free_entry;
|
||||
|
||||
entry->name_len = strlen(ns_name);
|
||||
ebis_insert(&namespace_tree_root, &entry->node);
|
||||
out:
|
||||
return entry;
|
||||
|
||||
/* free all allocated stuff and return entry */
|
||||
err_free_entry:
|
||||
ha_free(&entry);
|
||||
err_close_fd:
|
||||
close(fd);
|
||||
return entry;
|
||||
}
|
||||
|
||||
const struct netns_entry* netns_store_lookup(const char *ns_name, size_t ns_name_len)
|
||||
|
Loading…
Reference in New Issue
Block a user