-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix memory leak by removing tcpsocket after closing
- Loading branch information
Showing
1 changed file
with
3 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,9 @@ class TCPSocket : public BaseSocket | |
socket->Close(); | ||
if(socket->onSocketClosed) | ||
socket->onSocketClosed(errno); | ||
|
||
if (socket != nullptr) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
eminfedar
Author
Owner
|
||
delete socket; | ||
} | ||
|
||
void setTimeout(int seconds) | ||
|
deletting "socket" here is not good,
it is created outside of the library, and it must be deleted outside.
as a test case, i have created socket as a globale static variable:
TcpSocket socket;
then this line throw an exception.