Overview
Features
Download
Documentation
Community
Add-Ons & Services

Is there memory leak in HTTPSClientSession::sendRequest

Please post support and help requests here.

Is there memory leak in HTTPSClientSession::sendRequest

Postby sousarka » 16 Jun 2009, 23:39

Hello,

I am running a test C++ program using HTTPSClientSession under valgrind.
I am observing the following memory leak:

==18285== 150,040 (2,852 direct, 147,188 indirect) bytes in 31 blocks are definitely lost in loss record 3 of 7
==18285== at 0x40053C0: malloc (vg_replace_malloc.c:149)
==18285== by 0x4434C7D: (within /lib/libcrypto.so.0.9.8b)
==18285== by 0x44352FE: CRYPTO_malloc (in /lib/libcrypto.so.0.9.8b)
==18285== by 0x44A4596: (within /lib/libcrypto.so.0.9.8b)
==18285== by 0x44A7836: ASN1_item_ex_d2i (in /lib/libcrypto.so.0.9.8b)
==18285== by 0x44A7964: ASN1_item_d2i (in /lib/libcrypto.so.0.9.8b)
==18285== by 0x449F7A4: d2i_X509 (in /lib/libcrypto.so.0.9.8b)
==18285== by 0xB71EF9: ssl3_get_server_certificate (in /lib/libssl.so.0.9.8b)
==18285== by 0xB73C7B: ssl3_connect (in /lib/libssl.so.0.9.8b)
==18285== by 0xB85009: SSL_connect (in /lib/libssl.so.0.9.8b)
==18285== by 0xB7A213: ssl23_connect (in /lib/libssl.so.0.9.8b)
==18285== by 0xB85009: SSL_connect (in /lib/libssl.so.0.9.8b)

I have confirmed that this liak is caused by sendRequest method of HTTPSClientSession class.

Is there a fix for this memory leak?

Thanks.

Best Regards,
Soumen
+1 (415) 203-0242

Code: Select all
#include "Poco/Util/ServerApplication.h"
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/HTTPSStreamFactory.h"
#include "Poco/Net/FTPStreamFactory.h"
#include "Poco/SharedPtr.h"
#include "Poco/Net/AcceptCertificateHandler.h"
#include "Poco/Net/InvalidCertificateHandler.h"
#include "Poco/Net/SSLManager.h"
#include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/KeyConsoleHandler.h"
#include "Poco/Exception.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/StreamCopier.h"
#include <iostream>

using namespace Poco;
using namespace Poco::Net;
using Poco::Exception;
using Poco::StreamCopier;

class TerminalServer: public Poco::Util::ServerApplication
{
    public:

    int callBRCMAPI( HTTPSClientSession& session )
    {
        HTTPRequest request(HTTPRequest::HTTP_GET, "/nok/cell_poll.php?CellID=65876879&LAC=0&MNC=410&MCC=310", HTTPMessage::HTTP_1_1);
        request.add("Authorization" ,"Basic bm9raWE6bjBraWFfc3VwbDE=");
        session.sendRequest(request);

        HTTPResponse res;
        // std::istream& rs = session.receiveResponse(res);
        // std::cout << res.getStatus() << " " << res.getReason() << std::endl;
        // StreamCopier::copyStream(rs, std::cout);

        return 0;
    }
};

int main( int argc, char* argv[] )
{
    SharedPtr<InvalidCertificateHandler> ptrCert = new AcceptCertificateHandler(false);

    Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
    SSLManager::instance().initializeClient(0, ptrCert, ptrContext);

    // Broadcom host is GPSTimeStamp.glpals.com (66.35.236.22)
    HTTPSClientSession session("66.35.236.22", 443);

    for( int i = 0; i < 31; ++i )
    {
        TerminalServer ts;
        try
        {
            ts.callBRCMAPI( session );
        }
        catch (Exception& exc)
        {
            std::cerr << exc.displayText() << std::endl;
            return 1;
        }
    }
    return 0;
}
sousarka
 
Posts: 1
Joined: 16 Jun 2009, 23:22

Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests