Archived Forum Post

Index of archived forum posts

Question:

Digital Certificate sample seems to leak enormously

Feb 19 '13 at 04:48

About the sample located here: http://www.example-code.com/vcpp/cert_listLocalMachineCerts.asp

Using VS10 in debug mode, I see that there are lots of leaks when exiting the application. I experimented with Dispose (in C++) with no success but, using delete, I eliminated the leaks. Do we need and is it safe to use delete on the returned objects?

Modified code:

cs = ccs.OpenLocalSystemStore();

if (!(cs == 0 )) {

    CkCert *cert = 0;
    int numCerts;
    numCerts = cs->get_NumCertificates();
    int i;
    //  Print the distinguished name of each certificate
    for (i = 0; i <= numCerts - 1; i++) {
        cert = cs->GetCertificate(i);
        m_cLsCert.InsertString(-1, cert->subjectCN());
        cert->dispose();
        **delete cert;**
    }       
cs->dispose();  
**delete cs;**
}
else {
    printf("%s\n",ccs.lastErrorText());
}

Accepted Answer

All Chilkat objects returned by a Chilkat method must be deleted by the application.

I updated the online example.


Answer

That's interesting, however doesn't the digital certificate should be hidden or at least decoded in way that it cannot be altered? i mean its a very sensitive topic that should have this kind of modification.