state: plug memory leak when upserting

This commit is contained in:
Ariadne Conill 2020-09-08 15:02:39 -06:00
parent 8e4eb5d00c
commit 865bf7cac6

View file

@ -66,6 +66,8 @@ lif_state_read_path(struct lif_dict *state, const char *path)
void void
lif_state_upsert(struct lif_dict *state, const char *ifname, struct lif_interface *iface) lif_state_upsert(struct lif_dict *state, const char *ifname, struct lif_interface *iface)
{ {
lif_state_delete(state, ifname);
struct lif_state_record *rec = calloc(1, sizeof(*rec)); struct lif_state_record *rec = calloc(1, sizeof(*rec));
rec->mapped_if = strdup(iface->ifname); rec->mapped_if = strdup(iface->ifname);