Skip to content

Commit cdd26a9

Browse files
authored
std::shared_ptr Memory Leak
clientSocketHande and _rxBuffer are std::shared_ptr, the stop() call was not correctly releasing them and the operator= had similar problems fix for #3679
1 parent ed220bd commit cdd26a9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libraries/WiFi/src/WiFiClient.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,16 @@ WiFiClient::~WiFiClient()
188188
WiFiClient & WiFiClient::operator=(const WiFiClient &other)
189189
{
190190
stop();
191-
clientSocketHandle = other.clientSocketHandle;
192-
_rxBuffer = other._rxBuffer;
191+
clientSocketHandle.reset( other.clientSocketHandle ); // clientSocketHandle = other.clientSocketHandle;
192+
_rxBuffer.reset( other._rxBuffer); // _rxBuffer = other._rxBuffer;
193193
_connected = other._connected;
194194
return *this;
195195
}
196196

197197
void WiFiClient::stop()
198198
{
199-
clientSocketHandle = NULL;
200-
_rxBuffer = NULL;
199+
clientSocketHandle.reset(); // clientSocketHandle = NULL;
200+
_rxBuffer.reset(); // _rxBuffer = NULL;
201201
_connected = false;
202202
}
203203

0 commit comments

Comments
 (0)