Skip to content

Commit 3e737f4

Browse files
committed
WiFiClient: clean up ClientContext before connecting
Fixes #4497
1 parent 3ce888e commit 3e737f4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: 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)