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,13 +126,17 @@ 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);
if(c->cb->sent != NULL) {
c->cb->sent(c);
}
} else {
if(c->cb->timedout != NULL) {
c->cb->timedout(c);
}
}
}
}
/*---------------------------------------------------------------------------*/
static void
@ -191,7 +195,9 @@ mesh_send(struct mesh_conn *c, const rimeaddr_t *to)
PRINTF("mesh_send: could not send\n");
return 0;
}
if(c->cb->sent != NULL) {
c->cb->sent(c);
}
return 1;
}
/*---------------------------------------------------------------------------*/