From 77c5187a2e1b6912af73436bedb356370255f654 Mon Sep 17 00:00:00 2001 From: joxe Date: Thu, 23 Sep 2010 19:57:50 +0000 Subject: [PATCH] fixed bug where context is null but still referenced --- core/net/sicslowpan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index cf9daca04..12f26a91b 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: sicslowpan.c,v 1.44 2010/06/06 12:44:12 joxe Exp $ + * $Id: sicslowpan.c,v 1.45 2010/09/23 19:57:50 joxe Exp $ */ /** * \file @@ -777,19 +777,17 @@ uncompress_hdr_hc06(u16_t ip_len) { uint8_t sci = (iphc1 & SICSLOWPAN_IPHC_CID) ? RIME_IPHC_BUF[2] >> 4 : 0; - /* Source address */ - if((iphc1 & SICSLOWPAN_IPHC_SAM_11) != SICSLOWPAN_IPHC_SAM_00) { - context = - addr_context_lookup_by_number(sci); + /* Source address - check context != NULL only if SAM bits are != 0*/ + if (tmp != 0) { + context = addr_context_lookup_by_number(sci); if(context == NULL) { PRINTF("sicslowpan uncompress_hdr: error context not found\n"); return; - } else { - PRINTF("IPHC: found compressed source context for sci = %d\n", sci); } } - uncompress_addr(&SICSLOWPAN_IP_BUF->srcipaddr, context->prefix, - unc_ctxconf[tmp], + /* if tmp == 0 we do not have a context and therefore no prefix */ + uncompress_addr(&SICSLOWPAN_IP_BUF->srcipaddr, + tmp != 0 ? context->prefix : NULL, unc_ctxconf[tmp], (uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); } else { /* no compression and link local */