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:
likewise 2005-06-08 18:35:00 +00:00
parent bb76e69567
commit f9355136d8

View File

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