[socket] Use tcp_close for listen PCB cleanup in destructor

tcp_abort()/tcp_abandon() asserts pcb->state != LISTEN and accesses
fields beyond tcp_pcb_listen. Use tcp_close() instead and null pcb_
so the base destructor skips tcp_abort.
This commit is contained in:
J. Nick Koston
2026-03-01 08:43:27 -10:00
parent 3246662a09
commit 8c96ff8b61
@@ -552,7 +552,14 @@ ssize_t LWIPRawImpl::writev(const struct iovec *iov, int iovcnt) {
// ---- LWIPRawListenImpl methods ----
LWIPRawListenImpl::~LWIPRawListenImpl() {
// Base class destructor handles pcb_ cleanup via tcp_abort
// Listen PCBs must use tcp_close(), not tcp_abort().
// tcp_abandon() asserts pcb->state != LISTEN and would access
// fields that don't exist in the smaller tcp_pcb_listen struct.
// Close here and null pcb_ so the base destructor skips tcp_abort.
if (this->pcb_ != nullptr) {
tcp_close(this->pcb_);
this->pcb_ = nullptr;
}
}
void LWIPRawListenImpl::init() {