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 <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2015-12-03 17:48:55 +08:00 committed by Dirk Ziegelmeier
parent 3b60c855e1
commit 7f92660598

View File

@ -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 */