Check callback pointers to avoid calling a NULL pointer

This commit is contained in:
Adam Dunkels 2012-12-10 01:09:14 +01:00
parent aaa950ab17
commit 4324d74f12

View file

@ -126,11 +126,15 @@ found_route(struct route_discovery_conn *rdc, const rimeaddr_t *dest)
c->queued_data = NULL;
rt = route_lookup(dest);
if (rt != NULL) {
if(rt != NULL) {
multihop_resend(&c->multihop, &rt->nexthop);
c->cb->sent(c);
if(c->cb->sent != NULL) {
c->cb->sent(c);
}
} else {
c->cb->timedout(c);
if(c->cb->timedout != NULL) {
c->cb->timedout(c);
}
}
}
}
@ -191,7 +195,9 @@ mesh_send(struct mesh_conn *c, const rimeaddr_t *to)
PRINTF("mesh_send: could not send\n");
return 0;
}
c->cb->sent(c);
if(c->cb->sent != NULL) {
c->cb->sent(c);
}
return 1;
}
/*---------------------------------------------------------------------------*/