Add a check for the case when the parent neighbor may have gone away to avoid using a NULL pointer

This commit is contained in:
Adam Dunkels 2013-11-20 14:08:20 +01:00
parent 0ed7db0f9b
commit 490791eaa4

View File

@ -553,6 +553,9 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
if(lladdr != NULL) {
/* Add parent in rpl_parents */
p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr);
if(p == NULL) {
PRINTF("RPL: rpl_add_parent p NULL\n");
} else {
p->dag = dag;
p->rank = dio->rank;
p->dtsn = dio->dtsn;
@ -561,6 +564,7 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
}
}
return p;
}