lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] upd_new Bug


From: Ralf
Subject: [lwip-users] upd_new Bug
Date: Wed, 7 Jan 2004 12:30:20 +0100

Hello,
 
There is a small bug in upd_new (udp.c), if no memory is left (memp_malloc returns NULL) :
 
It is:
 
struct udp_pcb *
udp_new(void) {
  struct udp_pcb *pcb;
  pcb = memp_malloc(MEMP_UDP_PCB);
  /* could allocate UDP PCB? */
  if (pcb != NULL) {
    /* initialize PCB to all zeroes */
    memset(pcb, 0, sizeof(struct udp_pcb));
  }
 
  pcb->ttl = UDP_TTL;
 
  return pcb;
}
 
It should be:
 
struct udp_pcb *
udp_new(void) {
  struct udp_pcb *pcb;
  pcb = memp_malloc(MEMP_UDP_PCB);
  /* could allocate UDP PCB? */
  if (pcb != NULL) {
    /* initialize PCB to all zeroes */
    memset(pcb, 0, sizeof(struct udp_pcb));
    pcb->ttl = UDP_TTL;
  }
 
  return pcb;
}
 
 
 
Ralf
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]