If the mbufs linked list is corrupted, give the application a chance to properly shutdown itself without causing dataloss.
For now, this means slowly leaking the heap. Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- src/ip_input.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ip_input.c b/src/ip_input.c index ee52085..36962b5 100644 --- a/src/ip_input.c +++ b/src/ip_input.c @@ -185,6 +185,15 @@ void ip_input(struct mbuf *m) if (ip == NULL) return; m = dtom(slirp, ip); + if (m == NULL) { + /* The mbufs linked list is corrupted, we + * should properly shutdown the application. + * We prefer to leak a mbuf on the heap + * rather than allowing null dereference + * and eventual crash (data corruption). + */ + return; /* TODO warn the library consumer! */ + } } else if (fp) ip_freef(slirp, fp); -- 2.20.1