diff --git a/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c b/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c index 5e244c8126..0b284610bd 100644 --- a/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c +++ b/sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c @@ -59,6 +59,21 @@ void _receive(ng_pktsnip_t *pkt) uint8_t *dispatch; ng_netreg_entry_t *entry; + /* seize payload as a temporary variable */ + payload = ng_pktbuf_start_write(pkt); /* need to duplicate since pkt->next + * might get replaced */ + + if (payload == NULL) { + DEBUG("6lo: can not get write access on received packet\n"); +#if defined(DEVELHELP) && defined(ENABLE_DEBUG) + ng_pktbuf_stats(); +#endif + ng_pktbuf_release(pkt); + return; + } + + pkt = payload; /* reset pkt from temporary variable */ + LL_SEARCH_SCALAR(pkt, payload, type, NG_NETTYPE_SIXLOWPAN); if ((payload == NULL) || (payload->size < 1)) {