login about faq

After many tests to locate what was causing memory problem in my servers, I located this memory leak .. when my program initialized the certificate, I noticed that much memory was allocated, and nothing was released

Basically, my C++ code to work with certs is:

class Certificate
{
private:
    CkCert* _certificate;

public:
    Certificate();
    ~Certificate();

    std::string sigMessage(std::string msg);

private:
    void loadCertificateFile(std::string pathCertificado, std::string senhaCertificado);
};

The implementation:

Certificate::Certificate()
    : _certificate(new CkCert())
{
}

Certificate::~Certificate()
{
    if (_certificate != nullptr)
        delete _certificate;
}

std::string Certificate::sigMessage(std::string msg)
{
    CkCrypt2* crypt = new CkCrypt2();
    bool success = crypt->UnlockComponent(CHILKAT_KEY_CRYPT);
    if (success != true)
        throw "";

    crypt->put_EncodingMode("Base64");
    crypt->SetSigningCert(*_certificate);

    CkString* ckStr = new CkString();
    crypt->OpaqueSignStringENC(msg.c_str(), *ckStr);
    std::string ret(ckStr->getStringAnsi());

    delete crypt;
    delete ckStr;

    return ret;
}

void Certificate::loadCertificateFile(std::string pathCertificado, std::string senhaCertificado)
{
    if (!_certificate->LoadPfxFile(pathCertificado.c_str(), senhaCertificado.c_str()))
        throw "";
}

Look at the image: https://imgur.com/a/41AFi

Memory leak detection

asked Oct 03 '17 at 08:45

Alexandre%20Iwts's gravatar image

Alexandre Iwts
33

edited Oct 03 '17 at 08:47


  1. Please read this: https://www.chilkatsoft.com/p/p_109.asp
  2. Make sure you're using the latest version of Chilkat

99.9% of all reported "memory leaks" are false, and are because the programmer does not understand the information presented at https://www.chilkatsoft.com/p/p_109.asp

link

answered Oct 03 '17 at 09:39

chilkat's gravatar image

chilkat ♦♦
12.8k318386547

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×85
×51
×10
×4

Asked: Oct 03 '17 at 08:45

Seen: 461 times

Last updated: Oct 03 '17 at 09:39

powered by OSQA