mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 16:01:18 +01:00
Merge pull request #2187 from LudwigOrtmann/sixlowpan-malloc
sixlowpan: handle malloc error
This commit is contained in:
commit
e291ae4684
@ -605,8 +605,6 @@ void icmpv6_send_router_adv(ipv6_addr_t *addr, uint8_t sllao, uint8_t mtu, uint8
|
||||
else {
|
||||
lowpan_context_t c_tmp[NDP_6LOWPAN_CONTEXT_MAX];
|
||||
|
||||
contexts_len = 0;
|
||||
|
||||
for (int i = 0; i < NDP_6LOWPAN_CONTEXT_MAX; i++) {
|
||||
lowpan_context_t *ctx = abr_get_context(msg_abr, i);
|
||||
|
||||
@ -615,8 +613,17 @@ void icmpv6_send_router_adv(ipv6_addr_t *addr, uint8_t sllao, uint8_t mtu, uint8
|
||||
}
|
||||
}
|
||||
|
||||
contexts = (lowpan_context_t *)malloc(contexts_len * sizeof(lowpan_context_t));
|
||||
memcpy(contexts, c_tmp, contexts_len);
|
||||
if (contexts_len > 0) {
|
||||
contexts = (lowpan_context_t *)malloc(contexts_len * sizeof(lowpan_context_t));
|
||||
|
||||
if (contexts == NULL) {
|
||||
DEBUG("icmpv6_send_router_adv: no memory left");
|
||||
contexts_len = 0; /* HACK to skip over for loop below */
|
||||
}
|
||||
else {
|
||||
memcpy(contexts, c_tmp, contexts_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < contexts_len; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user