diff options
author | michele papalini <micpapal@cisco.com> | 2019-10-10 13:44:10 +0200 |
---|---|---|
committer | michele papalini <micpapal@cisco.com> | 2019-10-10 13:44:10 +0200 |
commit | d0c23b111015ed645272678bc229e1059337408f (patch) | |
tree | a60e55099d750c0dd92bef209299fec4215eef47 /hicn-light/src/hicn/processor/fibEntry.c | |
parent | e3d49850d80d6f603180cd5bd5ca0bfc0730f54a (diff) |
[HICN-315] memory leaks in hicn-light
Signed-off-by: michele papalini <micpapal@cisco.com>
Change-Id: I43f64d616fbbbc2b10b4a181529d087fb0afc56c
Diffstat (limited to 'hicn-light/src/hicn/processor/fibEntry.c')
-rw-r--r-- | hicn-light/src/hicn/processor/fibEntry.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c index 04e453ab9..f12dd506b 100644 --- a/hicn-light/src/hicn/processor/fibEntry.c +++ b/hicn-light/src/hicn/processor/fibEntry.c @@ -201,6 +201,7 @@ NumberSet * fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) { ConnectionTable * table = forwarder_GetConnectionTable(fibEntry->forwarder); NumberSet * nexthops; + bool dealloc_nexthops = false; policy_t policy = fibEntry_GetPolicy(fibEntry); /* Reset available next hops and start filtering */ @@ -214,6 +215,7 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) if (in_connection == ~0) { /* We might advertise among all available up connections */ nexthops = numberSet_Create(); + dealloc_nexthops = true; ConnectionList * list = connectionTable_GetEntries(table); for (size_t i = 0; i < connectionList_Length(list); i++) { @@ -226,7 +228,7 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) continue; numberSet_Add(nexthops, connection_GetConnectionId(conn)); } - + connectionList_Destroy(&list); } else { nexthops = (NumberSet*)fibEntry_GetNexthops(fibEntry); for (size_t k = 0; k < numberSet_Length(nexthops); k++) { @@ -247,8 +249,12 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) numberSet_Add(available_nexthops, conn_id); } - if (numberSet_Length(available_nexthops) > 0) + if (numberSet_Length(available_nexthops) > 0){ + if(dealloc_nexthops){ + numberSet_Release(&nexthops); + } return available_nexthops; + } } for (size_t k = 0; k < numberSet_Length(nexthops); k++) { @@ -297,6 +303,9 @@ fibEntry_GetAvailableNextHops(const FibEntry *fibEntry, unsigned in_connection) numberSet_Add(available_nexthops, conn_id); } + if(dealloc_nexthops) + numberSet_Release(&nexthops); + if (numberSet_Length(available_nexthops) == 0) return available_nexthops; |