Thank you so much for your help.  
"X509_free(peer);" was the solution. 

Please consider this case closed.



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nils Larsch via
RT
Sent: Tuesday, May 31, 2005 4:17 PM
To: Karim Sharif
Cc: [email protected]
Subject: Re: [openssl.org #1087] Memory leak - OpenSSL 0.9.7g


Karim Sharif via RT wrote:
> Hello,
>  
> I would like to report a memory leak in SSL_connect(). Following code 
> sample was check for memory leaks using "Purify" and show a 13K leak 
> in SSL_connect().

did you read the "* I think I've detected a memory leak, is this a bug?"
item in the FAQ ?

Didn't purify give you a somewhat more precise description where the mem
leak is ?

...
>     peer = SSL_get_peer_certificate(servercon);
>     if (peer != NULL) {
>         memset(sname, 0, sizeof(sname));
>         X509_NAME_oneline(X509_get_subject_name(peer), sname, 400);
>  
>         memset(iname, 0, sizeof(iname));
>         X509_NAME_oneline(X509_get_issuer_name(peer), iname, 400);
>  
>         memset(peerCN, 0, sizeof(peerCN));
>         X509_NAME_get_text_by_NID(X509_get_subject_name(peer), 13, 
> peerCN, 256);
>     }
>  
>     SSL_free(servercon);
>     SSL_CTX_free(ssl_ctx);

at least a "X509_free(peer);" is missing here, as
SSL_get_peer_certificate increases the reference counter of the X509
object.

>     return 1;
> }

Cheers,
Nils

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

Reply via email to