ldap: fix resource leak

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: ldap: fix resource leak
Date: 2006-11-05 00:43:37
Message-ID: 1162687417.5692.319.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Attached is a patch that fixes a minor error in CheckLDAPAuth() in 8.2:
when an LDAP handle is obtained via ldap_init(), it needs to be released
via ldap_unbind(). The code did this, but only if an error did not
occur.

I fixed this by adding the appropriate ldap_unbind() calls in error
control paths. An alternative would be to have a single place do the
error handling, and jump to that via goto. Anyone have any strong
feelings about which style is preferable here? I also didn't bother
checking the return value of ldap_unbind().

I also made a minor stylistic fix (use a "bool" for a boolean variable,
not an int).

Barring any objections, I'll apply this to HEAD tomorrow.

-Neil

Attachment Content-Type Size
ldap_error_handling-1.patch text/x-patch 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-11-05 04:34:52 Re: ldap: fix resource leak
Previous Message Josh Berkus 2006-11-04 23:00:34 Re: Design Considerations for New Authentication Methods

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-11-05 04:34:52 Re: ldap: fix resource leak
Previous Message Tom Lane 2006-11-04 23:06:54 WIP patch for tuple freezing issues