Skip to content

Commit

Permalink
Merge pull request #15435 from chrJost/TCP_reset_flag
Browse files Browse the repository at this point in the history
add nullpointer check in LWIP::socket_close
  • Loading branch information
0xc0170 committed Jul 11, 2023
2 parents f9c0cd2 + 67d845b commit 13f43cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connectivity/lwipstack/source/LWIPStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ nsapi_error_t LWIP::socket_close(nsapi_socket_t handle)
/* Check if TCP FSM is in ESTABLISHED state.
* Then give extra time for connection close handshaking until TIME_WAIT state.
* The purpose is to prevent eth/wifi driver stop and FIN ACK corrupt.
* This may happend if network interface disconnect follows immediately after socket_close.*/
if (NETCONNTYPE_GROUP(s->conn->type) == NETCONN_TCP && s->conn->pcb.tcp->state == ESTABLISHED) {
* This may happend if network interface disconnect follows immediately after socket_close.
* In case of a TCP RESET flag, the pcb structure is already deleted, therefore check for nullpointer.*/
if (NETCONNTYPE_GROUP(s->conn->type) == NETCONN_TCP && (nullptr == s->conn->pcb.tcp || s->conn->pcb.tcp->state == ESTABLISHED)) {
_event_flag.clear(TCP_CLOSED_FLAG);
netconn_shutdown(s->conn, false, true);
_event_flag.wait_any(TCP_CLOSED_FLAG, TCP_CLOSE_TIMEOUT);
Expand Down

0 comments on commit 13f43cc

Please sign in to comment.