Defensive programming: check for the argument being NULL.
This commit is contained in:
parent
b42ccaed1b
commit
c52fc2fd19
3 changed files with 28 additions and 4 deletions
|
@ -1022,6 +1022,10 @@ rpl_local_repair(rpl_instance_t *instance)
|
|||
{
|
||||
int i;
|
||||
|
||||
if(instance == NULL) {
|
||||
PRINTF("RPL: local repair requested for instance NULL\n");
|
||||
return;
|
||||
}
|
||||
PRINTF("RPL: Starting a local instance repair\n");
|
||||
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
|
||||
if(instance->dag_table[i].used) {
|
||||
|
|
|
@ -750,9 +750,27 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime)
|
|||
|
||||
/* Destination Advertisement Object */
|
||||
|
||||
if(parent == NULL) {
|
||||
PRINTF("RPL dao_output_target error parent NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dag = parent->dag;
|
||||
if(dag == NULL) {
|
||||
PRINTF("RPL dao_output_target error dag NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
instance = dag->instance;
|
||||
|
||||
if(instance == NULL) {
|
||||
PRINTF("RPL dao_output_target error instance NULL\n");
|
||||
return;
|
||||
}
|
||||
if(prefix == NULL) {
|
||||
PRINTF("RPL dao_output_target error prefix NULL\n");
|
||||
return;
|
||||
}
|
||||
#ifdef RPL_DEBUG_DAO_OUTPUT
|
||||
RPL_DEBUG_DAO_OUTPUT(parent);
|
||||
#endif
|
||||
|
|
|
@ -143,12 +143,14 @@ uip_ds6_nbr_t *
|
|||
uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
uip_ds6_nbr_t *nbr = nbr_table_head(ds6_neighbors);
|
||||
if(ipaddr != NULL) {
|
||||
while(nbr != NULL) {
|
||||
if(uip_ipaddr_cmp(&nbr->ipaddr, ipaddr)) {
|
||||
return nbr;
|
||||
}
|
||||
nbr = nbr_table_next(ds6_neighbors, nbr);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue