VC6.0 detected memory leaks in the following code! And the code do only 
PEM_read_bio_PrivateKey()!!

When I enabled the OpenSSL_add_ssl_algorithms() and the PEM_read_bio_PrivateKey
() finished sucessful, there is no memory leaks.
But when I disable(comment out) the Openssl_add_ssl_algorithms() and the 
PEM_read_bio_PrivateKey() failed, the following code caused memory leaks.
As the code showed, I have called ERR_clear_error(), ERR_remove_state(0), 
EVP_cleanup(), and ERR_free_strings(), but the memory leaks still exists!!


        EVP_PKEY* pKey = NULL;
        BIO *in = NULL;
        char filename[] = "ca\\cakey.pem";
        char passwd[] = "passwd";

        if ((in = BIO_new(BIO_s_file())) == NULL)
                TRACE("cannot create a bio!\n");

        if (BIO_read_filename(in, filename) <= 0)
                TRACE("cannot open file\n");

        //OpenSSL_add_ssl_algorithms();
        SSL_load_error_strings();

        pKey = PEM_read_bio_PrivateKey(in,NULL,NULL, passwd);

        FILE *fp = fopen("memleaks.txt", "w+");
        ERR_print_errors_fp(fp);
        fclose(fp);

        ERR_clear_error();

        ERR_remove_state(0);
        EVP_cleanup();

        ERR_free_strings();

        if (pKey != NULL)
                EVP_PKEY_free(pKey);

        if (in != NULL)
                BIO_free(in);

Anyone have an idea?

zhang
-------------------------------------
��ӭʹ�ñ����籨�ֵ���ѵ����ʼ�ϵͳ!
 http://btamail.net.cn  or http://mail.bta.net.cn
�ͷ����ĵ绰��223 ����ѣ�
��ӭ��169����,�绰:169,�û���:169,����:169.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to