ospf6d: Fix memory allocation issues in SPF

* ospf6_area.c: Call ospf6_spf_table_finish() before deleting the spf
    table.  This ensures that the associated ospf6_vertex structures
    are also freed.
* ospf6_spf.c: Only allocate a priority queue when a spf calculation
    is actually performed.
This commit is contained in:
Tom Goff 2010-11-10 13:02:38 -08:00 committed by Denis Ovsienko
parent f7c91fc330
commit 158dd4d00e
2 changed files with 6 additions and 4 deletions

View File

@ -199,6 +199,7 @@ ospf6_area_delete (struct ospf6_area *oa)
ospf6_lsdb_delete (oa->lsdb); ospf6_lsdb_delete (oa->lsdb);
ospf6_lsdb_delete (oa->lsdb_self); ospf6_lsdb_delete (oa->lsdb_self);
ospf6_spf_table_finish (oa->spf_table);
ospf6_route_table_delete (oa->spf_table); ospf6_route_table_delete (oa->spf_table);
ospf6_route_table_delete (oa->route_table); ospf6_route_table_delete (oa->route_table);

View File

@ -391,10 +391,6 @@ ospf6_spf_calculation (u_int32_t router_id,
caddr_t lsdesc; caddr_t lsdesc;
struct ospf6_lsa *lsa; struct ospf6_lsa *lsa;
/* initialize */
candidate_list = pqueue_create ();
candidate_list->cmp = ospf6_vertex_cmp;
ospf6_spf_table_finish (result_table); ospf6_spf_table_finish (result_table);
/* Install the calculating router itself as the root of the SPF tree */ /* Install the calculating router itself as the root of the SPF tree */
@ -403,6 +399,11 @@ ospf6_spf_calculation (u_int32_t router_id,
router_id, oa->lsdb); router_id, oa->lsdb);
if (lsa == NULL) if (lsa == NULL)
return; return;
/* initialize */
candidate_list = pqueue_create ();
candidate_list->cmp = ospf6_vertex_cmp;
root = ospf6_vertex_create (lsa); root = ospf6_vertex_create (lsa);
root->area = oa; root->area = oa;
root->cost = 0; root->cost = 0;