Defensive programming: check for the argument being NULL.
This commit is contained in:
parent
b42ccaed1b
commit
c52fc2fd19
@ -1022,6 +1022,10 @@ rpl_local_repair(rpl_instance_t *instance)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if(instance == NULL) {
|
||||||
|
PRINTF("RPL: local repair requested for instance NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
PRINTF("RPL: Starting a local instance repair\n");
|
PRINTF("RPL: Starting a local instance repair\n");
|
||||||
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
|
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
|
||||||
if(instance->dag_table[i].used) {
|
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 */
|
/* Destination Advertisement Object */
|
||||||
|
|
||||||
|
if(parent == NULL) {
|
||||||
|
PRINTF("RPL dao_output_target error parent NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dag = parent->dag;
|
dag = parent->dag;
|
||||||
|
if(dag == NULL) {
|
||||||
|
PRINTF("RPL dao_output_target error dag NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
instance = dag->instance;
|
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
|
#ifdef RPL_DEBUG_DAO_OUTPUT
|
||||||
RPL_DEBUG_DAO_OUTPUT(parent);
|
RPL_DEBUG_DAO_OUTPUT(parent);
|
||||||
#endif
|
#endif
|
||||||
|
@ -143,12 +143,14 @@ uip_ds6_nbr_t *
|
|||||||
uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr)
|
uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr)
|
||||||
{
|
{
|
||||||
uip_ds6_nbr_t *nbr = nbr_table_head(ds6_neighbors);
|
uip_ds6_nbr_t *nbr = nbr_table_head(ds6_neighbors);
|
||||||
|
if(ipaddr != NULL) {
|
||||||
while(nbr != NULL) {
|
while(nbr != NULL) {
|
||||||
if(uip_ipaddr_cmp(&nbr->ipaddr, ipaddr)) {
|
if(uip_ipaddr_cmp(&nbr->ipaddr, ipaddr)) {
|
||||||
return nbr;
|
return nbr;
|
||||||
}
|
}
|
||||||
nbr = nbr_table_next(ds6_neighbors, nbr);
|
nbr = nbr_table_next(ds6_neighbors, nbr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user