Skip to content

Commit 98b0e23

Browse files
author
Arto Kinnunen
authored
Fix memory leak when advertising route (ARMmbed#1814)
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.
1 parent b5d276d commit 98b0e23

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

source/ipv6_stack/protocol_ipv6.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,14 @@ void ipv6_stack_route_advert_update(uint8_t *address, uint8_t prefixLength, uint
394394
return;
395395
}
396396

397+
if (addr_interface_gp_prefix_compare(cur, address) == 0) {
398+
return;
399+
}
397400

398-
399-
if (addr_interface_gp_prefix_compare(cur, address) != 0) {
400-
ns_list_foreach(ipv6_interface_route_on_link_t, cur_prefix, &route_on_link) {
401-
if ((cur_prefix->prefix_len == prefixLength) && bitsequal(cur_prefix->prefix, address, prefixLength)) {
402-
cur_prefix->routePrefer = routePrefer;
403-
return;
404-
}
401+
ns_list_foreach(ipv6_interface_route_on_link_t, cur_prefix, &route_on_link) {
402+
if ((cur_prefix->prefix_len == prefixLength) && bitsequal(cur_prefix->prefix, address, prefixLength)) {
403+
cur_prefix->routePrefer = routePrefer;
404+
return;
405405
}
406406
}
407407

0 commit comments

Comments
 (0)