ng_pktbuf_static: check if pkt is in buffer before derefencing in ng_pktbuf_release
This commit is contained in:
parent
ffc6d31bab
commit
420d5e48ca
@ -141,6 +141,8 @@ void ng_pktbuf_hold(ng_pktsnip_t *pkt, unsigned int num);
|
||||
* @brief Decreases ng_pktsnip_t::users of @p pkt atomically and removes it if it
|
||||
* reaches 0.
|
||||
*
|
||||
* @pre All snips of @p pkt must be in the packet buffer.
|
||||
*
|
||||
* @param[in] pkt A packet.
|
||||
*/
|
||||
void ng_pktbuf_release(ng_pktsnip_t *pkt);
|
||||
|
||||
@ -198,7 +198,9 @@ void ng_pktbuf_release(ng_pktsnip_t *pkt)
|
||||
{
|
||||
mutex_lock(&_mutex);
|
||||
while (pkt) {
|
||||
ng_pktsnip_t *tmp = pkt->next;
|
||||
ng_pktsnip_t *tmp;
|
||||
assert(_pktbuf_contains(pkt));
|
||||
tmp = pkt->next;
|
||||
if (pkt->users == 1) {
|
||||
pkt->users = 0; /* not necessary but to be on the safe side */
|
||||
_pktbuf_free(pkt->data, pkt->size);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user