Safeguard against NULL arguments
This commit is contained in:
parent
928cb1fc84
commit
70f9f075a0
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: collect-neighbor.c,v 1.9 2011/01/09 21:20:05 adamdunkels Exp $
|
||||
* $Id: collect-neighbor.c,v 1.10 2011/01/10 15:08:52 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -144,6 +144,11 @@ collect_neighbor_list_add(struct collect_neighbor_list *neighbors_list,
|
|||
{
|
||||
struct collect_neighbor *n;
|
||||
|
||||
if(addr == NULL) {
|
||||
PRINTF("collect_neighbor_list_add: attempt to add NULL addr\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRINTF("collect_neighbor_add: adding %d.%d\n", addr->u8[0], addr->u8[1]);
|
||||
|
||||
/* Check if the collect_neighbor is already on the list. */
|
||||
|
@ -195,8 +200,10 @@ collect_neighbor_list_add(struct collect_neighbor_list *neighbors_list,
|
|||
if(nrtmetric < worst_rtmetric) {
|
||||
n = worst_neighbor;
|
||||
}
|
||||
PRINTF("collect_neighbor_add: not on list, not allocated, recycling %d.%d\n",
|
||||
n->addr.u8[0], n->addr.u8[1]);
|
||||
if(n != NULL) {
|
||||
PRINTF("collect_neighbor_add: not on list, not allocated, recycling %d.%d\n",
|
||||
n->addr.u8[0], n->addr.u8[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if(n != NULL) {
|
||||
|
|
Loading…
Reference in a new issue