aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2024-04-24 02:39:25 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-04-24 02:39:40 +0200
commit41b92e2731933a820658fc6e9a69732bf30e6635 (patch)
treebbd0c7f661f8c75d448de823631ca65104f47a55
parentc195d025b031f458acb2e603395afd49b19f0a2a (diff)
downloadslirp-41b92e2731933a820658fc6e9a69732bf30e6635.zip
slirp-41b92e2731933a820658fc6e9a69732bf30e6635.tar.gz
slirp-41b92e2731933a820658fc6e9a69732bf30e6635.tar.bz2
mbuf: Be extra careful with freed pointer
As coverity reports, we are not supposed to do anything with a freed pointer, not even assigning it to m. So break the loop before doing so.
-rw-r--r--src/mbuf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mbuf.c b/src/mbuf.c
index edcd99c..70c39be 100644
--- a/src/mbuf.c
+++ b/src/mbuf.c
@@ -39,7 +39,7 @@ static void m_cleanup_list(struct slirp_quehead *list_head, bool pkts)
next = m->m_next;
last = false;
- do {
+ while (1) {
next2 = m->m_nextpkt;
if (pkts) {
@@ -54,8 +54,11 @@ static void m_cleanup_list(struct slirp_quehead *list_head, bool pkts)
}
g_free(m);
+
+ if (last)
+ break;
m = next2;
- } while (!last);
+ };
m = next;
}