Skip to content

Commit 95b1348

Browse files
igrrdevyte
authored andcommitted
WiFiClient: clean up ClientContext before connecting (#4516)
Fixes #4497
1 parent d5cbd91 commit 95b1348

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/ESP8266WiFi/src/WiFiClient.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
112112
ip_addr_t addr;
113113
addr.addr = ip;
114114

115-
if (_client)
115+
if (_client) {
116116
stop();
117+
_client->unref();
118+
_client = nullptr;
119+
}
117120

118121
// if the default interface is down, tcp_connect exits early without
119122
// ever calling tcp_err

0 commit comments

Comments
 (0)