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

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