Merge pull request #160 from e120guru/develop

TSCH: defensive programming: check for NULL pointer before attempting to send keep-alive
This commit is contained in:
Simon Duquennoy 2017-11-09 19:00:18 +01:00 committed by GitHub
commit 4f89114404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -304,13 +304,17 @@ keepalive_send(void *ptr)
{
if(tsch_is_associated) {
struct tsch_neighbor *n = tsch_queue_get_time_source();
/* Simply send an empty packet */
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
NETSTACK_MAC.send(keepalive_packet_sent, NULL);
LOG_INFO("sending KA to ");
LOG_INFO_LLADDR(&n->addr);
LOG_INFO_("\n");
if(n != NULL) {
/* Simply send an empty packet */
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
NETSTACK_MAC.send(keepalive_packet_sent, NULL);
LOG_INFO("sending KA to ");
LOG_INFO_LLADDR(&n->addr);
LOG_INFO_("\n");
} else {
LOG_ERR("no timesource - KA not sent\n");
}
}
}
/*---------------------------------------------------------------------------*/