From d9ecc0b9bb0a97ec7f5cfe7553fc310287f817d5 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Tue, 3 Dec 2019 12:23:56 +0100 Subject: [PATCH] gnrc_sixlowpan_frag_vrb: append intervals of given base if entry exists Otherwise the list in `base->ints` will get lost. --- .../frag/vrb/gnrc_sixlowpan_frag_vrb.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c index 9a78e26aca..a1e15ad88b 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c @@ -80,6 +80,34 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_add( vrbe->super.dst_len, addr_str), vrbe->out_tag); } + /* _equal_index() => append intervals of `base`, so they don't get + * lost. We use append, so we don't need to change base! */ + else if (base->ints != NULL) { + gnrc_sixlowpan_frag_rb_int_t *tmp = vrbe->super.ints; + + if (tmp != base->ints) { + /* base->ints is not already vrbe->super.ints */ + if (tmp != NULL) { + /* iterate before appending and check if `base->ints` is + * not already part of list */ + while (tmp->next != NULL) { + if (tmp == base->ints) { + tmp = NULL; + } + /* cppcheck-suppress nullPointer + * (reason: possible bug in cppcheck, tmp can't + * clearly be a NULL pointer here) */ + tmp = tmp->next; + } + if (tmp != NULL) { + tmp->next = base->ints; + } + } + else { + vrbe->super.ints = base->ints; + } + } + } break; } }