pppos_input_tcpip: fix pbuf leak if tcpip_input returns error, use pbuf_take instead of duplicate copy code

This commit is contained in:
goldsimon 2015-03-19 07:14:33 +01:00
parent c73daef2a1
commit b135a0aa49

View File

@ -487,19 +487,19 @@ pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l)
{ {
struct pbuf *p, *n; struct pbuf *p, *n;
u8_t *cur; u8_t *cur;
err_t err;
p = pbuf_alloc(PBUF_RAW, l, PBUF_POOL); p = pbuf_alloc(PBUF_RAW, l, PBUF_POOL);
if (!p) { if (!p) {
return ERR_MEM; return ERR_MEM;
} }
pbuf_take(p, s, l);
cur = s; err = tcpip_input(p, ppp_netif(ppp));
for (n = p; n; n = n->next) { if (err != ERR_OK) {
MEMCPY(n->payload, cur, n->len); pbuf_free(p);
cur += n->len;
} }
return err;
return tcpip_input(p, ppp_netif(ppp));
} }
/* called from TCPIP thread */ /* called from TCPIP thread */