On Wed, Oct 02, 2002, David Sloat wrote:

> 
> Hi
> 
> I've implemented a trimmed down version of the ocsp application (apps/ocsp.c)
> and when I execute the code, I get a segmentation fault while trying to free
> the OCSP_* structures.  I've changed the order of the OCSP_*_free calls, but
> it always seg faults on one of them.  The "free" calls in particular are the ones
> at the very end of the function - which represents the successful case.  Usually
> the second "free" call in the list is the one to seg fault.
> 
> I noticed someone had a similar issue a few months back - but I was unable to
> send an email to that person to see if there was any resolution to the problem
> (title of message thread: "OCSP memory leaks").
> 
> Attached is the code sample...
> 

Some of the newer functions in OpenSSL follow a naming convention. When you
have a function like, foo_get0_bar or foo_add1_bar() the '0' and the '1'
indicates how the added or obtained structure behaves. 

In the '0' case the structure added or obtained will be freed when the parent
structure is freed and so it should *not* be freed itself: otherwise the same
thing may be freed twice typically resulting in segmentation violations.

In the '1' case the structure should be freed as well as the parent.

So in your example the function OCSP_request_add0_id actually swallows the
passed cert id, so you should not free up the certid later: it will be
automatically freed up when the request is freed.

Steve.
--
Dr. Stephen Henson      [EMAIL PROTECTED]            
OpenSSL Project         http://www.openssl.org/~steve/
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to