SLikeSoft / SLikeNet

SLikeNetâ„¢ is an Open Source/Free Software cross-platform network engine written in C++ and specifially designed for games (and applications which have comparable requirements on a network engine like games) building upon the discontinued RakNet network engine which had more than 13 years of active development.
https://www.slikenet.com/
Other
395 stars 62 forks source link

Memory leaks in HTTPConnection2.cpp #44

Open Tomash667 opened 5 years ago

Tomash667 commented 5 years ago

HTTPConnection2 have some memory leaks. After adding request it must be processed and then user have to get response, otherwise it will leak (for example user quit game before response is received or processed).

Example solution:

HTTPConnection2::~HTTPConnection2()
{
    for(unsigned int i = 0, count = pendingRequests.Size(); i < count; ++i)
        SLNet::OP_DELETE(pendingRequests[i], _FILE_AND_LINE_);
    for(unsigned int i = 0, count = sentRequests.Size(); i < count; ++i)
        SLNet::OP_DELETE(sentRequests[i], _FILE_AND_LINE_);
    for(unsigned int i = 0, count = completedRequests.Size(); i < count; ++i)
        SLNet::OP_DELETE(completedRequests[i], _FILE_AND_LINE_);
}

I hereby declare I've read and agree to the current CLA as provided under https://github.com/SLikeSoft/SLikeNet/blob/master/.github/CONTRIBUTING.md

Luke1410 commented 5 years ago

Hi Tomash, thanks for the report and the suggested fix. I've applied a variant of the suggested code change to the current trunk/master and the fix should be integrated in the next version of SLikeNet.

Internal issue number: SLNET-259.

Do you want to be listed in the acknowledgment section of the accompanied readme file as well for your contribution?

Tomash667 commented 5 years ago

Sure, why not.