From 278e8f53b7c464b8a7e0585ed15cc6c229e3a35a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 14 Nov 2024 15:27:05 +0100 Subject: [PATCH] sys/net/gnrc_pktbuf: fail assertion if illegal memory was freed --- sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c b/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c index 72f2442ee3..80b33908d7 100644 --- a/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c +++ b/sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c @@ -465,7 +465,12 @@ void gnrc_pktbuf_free_internal(void *data, size_t size) size_t bytes_at_end; _unused_t *new = (_unused_t *)data, *prev = NULL, *ptr = _first_unused; + if (data == NULL) { + return; + } + if (!gnrc_pktbuf_contains(data)) { + assert(0); return; }