Fix possible null pointer dereference

This commit is contained in:
Martin Lenders 2014-02-20 02:29:33 +01:00
parent c5230a4a0a
commit 4119e15e6b
3 changed files with 8 additions and 4 deletions

View File

@ -474,9 +474,9 @@ int print_and_prompt(struct ftdi_device_list *devlist)
if (input[last] == '\n') { if (input[last] == '\n') {
input[last] = '\0'; input[last] = '\0';
} }
}
sscanf(s, "%i", &sel); sscanf(s, "%i", &sel);
}
return sel; return sel;
} }

View File

@ -1467,12 +1467,13 @@ ccnl_core_RX(struct ccnl_relay_s *relay, int ifndx, unsigned char *data,
DEBUGMSG(14, "ccnl_core_RX ifndx=%d, %d bytes\n", ifndx, datalen); DEBUGMSG(14, "ccnl_core_RX ifndx=%d, %d bytes\n", ifndx, datalen);
from = ccnl_get_face_or_create(relay, ifndx, sender_id); from = ccnl_get_face_or_create(relay, ifndx, sender_id);
DEBUGMSG(1, "ccnl_core_RX: faceid=%d frag=%p\n", from->faceid, (void *) from->frag);
if (!from) { if (!from) {
return; return;
} }
DEBUGMSG(1, "ccnl_core_RX: faceid=%d frag=%p\n", from->faceid, (void *) from->frag);
ccnl_core_RX_datagram(relay, from, &data, &datalen); ccnl_core_RX_datagram(relay, from, &data, &datalen);
} }

View File

@ -286,12 +286,15 @@ rpl_parent_t *rpl_find_preferred_parent(void)
void rpl_parent_update(rpl_parent_t *parent) void rpl_parent_update(rpl_parent_t *parent)
{ {
rpl_dodag_t *my_dodag = rpl_get_my_dodag(); rpl_dodag_t *my_dodag = rpl_get_my_dodag();
uint16_t old_rank = my_dodag->my_rank; uint16_t old_rank;
if (my_dodag == NULL) { if (my_dodag == NULL) {
DEBUG("Not part of a dodag - this should not happen"); DEBUG("Not part of a dodag - this should not happen");
return; return;
} }
old_rank = my_dodag->my_rank;
/* update Parent lifetime */ /* update Parent lifetime */
if (parent != NULL) { if (parent != NULL) {
parent->lifetime = my_dodag->default_lifetime * my_dodag->lifetime_unit; parent->lifetime = my_dodag->default_lifetime * my_dodag->lifetime_unit;