[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#4483) Confusion in freeing BerElement in abnormal conditions



On Sat, 2006-04-08 at 15:49 +0000, ando@sys-net.it wrote:
> Full_Name: Pierangelo Masarati
> Version: HEAD,re23,re24
> OS: irrelevant
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (87.28.220.33)
> Submitted by: ando
> 
> 
> In liblber/io.c:br_flush(), even when requested to free the BerElement arg, the
> function doesn't free it in some abnormal conditions; however,
> libldap/unbind.c:ldap_send_unbind() calls ber_flush() with freeit set, and, in
> case of error, frees the value once more.
> 
> liblber/io.c  1.111 -> 1.112
> libldap/unbind.c  1.58 -> 1.59
> 
> All other calls to ber_flush() are consistent, i.e. either don't set freeit, and
> handle failures, or set it and don't re-free it.

Actually, the behavior in ldap_send_unbind() was correct, since the
BerElement was explicitly freed only in case of error, when not freed by
ber_flush() itself.  The erroneous behavior was in do_abandon(), where
even in case of error, when ber_flush() didn't free the BerElement so it
leaked.  I believe after this change the interface is much cleaner: if
called with freeit set, ber_flush() always frees the BerElement,
regardless of the return status.  In case the caller wants to handle
errors, it has to call ber_flush() with freeit unset, and free it
explicitly in case of success or handle it otherwise.

p.




Ing. Pierangelo Masarati
Responsabile Open Solution
OpenLDAP Core Team

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
http://www.sys-net.it
------------------------------------------
Office:   +39.02.23998309          
Mobile:   +39.333.4963172
Email:    pierangelo.masarati@sys-net.it
------------------------------------------