mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-23 21:14:18 +00:00
2005-06-08 Leon Woestenberg <leon.woestenberg@gmx.net>
* udp.c: Fixed memory leak; when ip_route() failed, a possibly allocated q was never de-allocated. Fixed by called ip_route() before allocating q.
This commit is contained in:
parent
bb76e69567
commit
f9355136d8
@ -66,7 +66,6 @@ struct udp_pcb *udp_pcbs = NULL;
|
||||
|
||||
static struct udp_pcb *pcb_cache = NULL;
|
||||
|
||||
|
||||
void
|
||||
udp_init(void)
|
||||
{
|
||||
@ -410,6 +409,14 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
/* find the outgoing network interface for this packet */
|
||||
netif = ip_route(&(pcb->remote_ip));
|
||||
/* no outgoing network interface could be found? */
|
||||
if (netif == NULL) {
|
||||
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
||||
UDP_STATS_INC(udp.rterr);
|
||||
return ERR_RTE;
|
||||
}
|
||||
|
||||
/* not enough space to add an UDP header to first pbuf in given p chain? */
|
||||
if (pbuf_header(p, UDP_HLEN)) {
|
||||
@ -437,14 +444,6 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
||||
/* in UDP, 0 checksum means 'no checksum' */
|
||||
udphdr->chksum = 0x0000;
|
||||
|
||||
/* find the outgoing network interface for this packet */
|
||||
netif = ip_route(&(pcb->remote_ip));
|
||||
/* no outgoing network interface could be found? */
|
||||
if (netif == NULL) {
|
||||
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
||||
UDP_STATS_INC(udp.rterr);
|
||||
return ERR_RTE;
|
||||
}
|
||||
/* PCB local address is IP_ANY_ADDR? */
|
||||
if (ip_addr_isany(&pcb->local_ip)) {
|
||||
/* use outgoing network interface IP address as source address */
|
||||
|
Loading…
Reference in New Issue
Block a user