diff --git a/src/core/tcp.c b/src/core/tcp.c index fbfd1314..ce03c816 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -583,6 +583,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) tcp_free(pcb); } else { int send_rst = 0; + u16_t local_port = 0; enum tcp_state last_state; seqno = pcb->snd_nxt; ackno = pcb->rcv_nxt; @@ -597,6 +598,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) } } else { send_rst = reset; + local_port = pcb->local_port; TCP_PCB_REMOVE_ACTIVE(pcb); } if (pcb->unacked != NULL) { @@ -613,7 +615,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) tcp_backlog_accepted(pcb); if (send_rst) { LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); - tcp_rst(pcb, seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port); + tcp_rst(pcb, seqno, ackno, &pcb->local_ip, &pcb->remote_ip, local_port, pcb->remote_port); } last_state = pcb->state; tcp_free(pcb);