mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
pppos_input_tcpip: fix pbuf leak if tcpip_input returns error, use pbuf_take instead of duplicate copy code
This commit is contained in:
parent
c73daef2a1
commit
b135a0aa49
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user