diff --git a/ethermess.c b/ethermess.c index 954955c..ec99b3a 100644 --- a/ethermess.c +++ b/ethermess.c @@ -73,6 +73,12 @@ ssize_t msgid_cache_lookup(const unsigned char mac[6]) { ssize_t msgid_cache_add(const unsigned char mac[6]) { ssize_t index = next_slot++; + // If we are adding into a new slot (instead of overwriting one), + // expand the fill pointer + if (msgid_cache_fill < index) { + msgid_cache_fill++; + } + memcpy(msgid_cache[index].other_mac, mac, sizeof(msgid_cache[index].other_mac)); msgid_cache[index].know_send = false; msgid_cache[index].know_receive = false;