Skip to content

Commit

Permalink
Fix memory leak when advertising route (ARMmbed#1814)
Browse files Browse the repository at this point in the history
Leak of 40 bytes occurs every time ipv6_stack_route_advert_update is
called. Do new prefix allocation only if prefix is not found from
interface address list and prefix is not already allocated.
  • Loading branch information
Arto Kinnunen authored Sep 11, 2018
1 parent b5d276d commit 98b0e23
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/ipv6_stack/protocol_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ void ipv6_stack_route_advert_update(uint8_t *address, uint8_t prefixLength, uint
return;
}

if (addr_interface_gp_prefix_compare(cur, address) == 0) {
return;
}


if (addr_interface_gp_prefix_compare(cur, address) != 0) {
ns_list_foreach(ipv6_interface_route_on_link_t, cur_prefix, &route_on_link) {
if ((cur_prefix->prefix_len == prefixLength) && bitsequal(cur_prefix->prefix, address, prefixLength)) {
cur_prefix->routePrefer = routePrefer;
return;
}
ns_list_foreach(ipv6_interface_route_on_link_t, cur_prefix, &route_on_link) {
if ((cur_prefix->prefix_len == prefixLength) && bitsequal(cur_prefix->prefix, address, prefixLength)) {
cur_prefix->routePrefer = routePrefer;
return;
}
}

Expand Down

0 comments on commit 98b0e23

Please sign in to comment.