From 7f926605987146715064bafb531822c64c238f1d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 3 Dec 2015 17:48:55 +0800 Subject: [PATCH] icmp: Fix memory leak in icmp_input() error paths Ensure the newly allocated packet buffer is freed in error paths. Signed-off-by: Axel Lin --- src/core/ipv4/icmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index ea7dd496..25d2584c 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -164,11 +164,13 @@ icmp_input(struct pbuf *p, struct netif *inp) /* switch r->payload back to icmp header */ if (pbuf_header(r, -hlen)) { LWIP_ASSERT("icmp_input: moving r->payload to icmp header failed\n", 0); + pbuf_free(r); goto icmperr; } /* copy the rest of the packet without ip header */ if (pbuf_copy(r, p) != ERR_OK) { LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0); + pbuf_free(r); goto icmperr; } /* free the original p */