diff options
| author | Russ White <russ@riw.us> | 2023-05-02 10:31:10 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-02 10:31:10 -0400 | 
| commit | 9ab0661b89f3c3b9db76cbe9f0138a8dbd206a1b (patch) | |
| tree | c94e9be89626559de64c10c1ef76b6fef921ffdf /lib/link_state.c | |
| parent | 856e85e910c3f2fce4158bfc91b7333905de682b (diff) | |
| parent | 30584b6f6a5d4d8e1d23a9574d4c9b5def75a4ba (diff) | |
Merge pull request #13235 from Orange-OpenSource/link-state
lib: Fix memory leaks in Link State library
Diffstat (limited to 'lib/link_state.c')
| -rw-r--r-- | lib/link_state.c | 16 | 
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/link_state.c b/lib/link_state.c index 752030cd47..58727a568b 100644 --- a/lib/link_state.c +++ b/lib/link_state.c @@ -497,7 +497,6 @@ void ls_vertex_del(struct ls_ted *ted, struct ls_vertex *vertex)  	/* Then remove Vertex from Link State Data Base and free memory */  	vertices_del(&ted->vertices, vertex);  	XFREE(MTYPE_LS_DB, vertex); -	vertex = NULL;  }  void ls_vertex_del_all(struct ls_ted *ted, struct ls_vertex *vertex) @@ -956,7 +955,10 @@ struct ls_subnet *ls_find_subnet(struct ls_ted *ted,  {  	struct ls_subnet subnet = {}; -	subnet.key = *prefix; +	if (!prefix) +		return NULL; + +	prefix_copy(&subnet.key, prefix);  	return subnets_find(&ted->subnets, &subnet);  } @@ -1779,9 +1781,10 @@ struct ls_vertex *ls_msg2vertex(struct ls_ted *ted, struct ls_message *msg,  	case LS_MSG_EVENT_DELETE:  		vertex = ls_find_vertex_by_id(ted, node->adv);  		if (vertex) { -			if (delete) +			if (delete) {  				ls_vertex_del_all(ted, vertex); -			else +				vertex = NULL; +			} else  				vertex->status = DELETE;  		}  		break; @@ -1858,9 +1861,10 @@ struct ls_subnet *ls_msg2subnet(struct ls_ted *ted, struct ls_message *msg,  	case LS_MSG_EVENT_DELETE:  		subnet = ls_find_subnet(ted, &pref->pref);  		if (subnet) { -			if (delete) +			if (delete) {  				ls_subnet_del_all(ted, subnet); -			else +				subnet = NULL; +			} else  				subnet->status = DELETE;  		}  		break;  | 
