diff options
| author | 2013-03-11 19:53:54 +0100 | |
|---|---|---|
| committer | 2013-03-29 01:09:34 +0100 | |
| commit | c2549b040243e0fcaac0ec2e6d461980cda7f5f4 (patch) | |
| tree | 8d53bb2c3fd6aa6e5cceb124e55a9aaaa2fbc023 /src/modules | |
| parent | Fix premature overwriting of OLDTIME that resulted in time drifts never being... (diff) | |
| download | inspircd++-c2549b040243e0fcaac0ec2e6d461980cda7f5f4.tar.gz inspircd++-c2549b040243e0fcaac0ec2e6d461980cda7f5f4.tar.bz2 inspircd++-c2549b040243e0fcaac0ec2e6d461980cda7f5f4.zip | |
m_ldapoper Fix memory leak
See 1813369adecc1efc9812e90c40c21dc32e4965c9 for details
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/extra/m_ldapoper.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp index e9e25630c..69131f7bc 100644 --- a/src/modules/extra/m_ldapoper.cpp +++ b/src/modules/extra/m_ldapoper.cpp @@ -35,6 +35,31 @@ /* $ModDesc: Adds the ability to authenticate opers via LDAP */ /* $LinkerFlags: -lldap */ +struct RAIILDAPString +{ + char *str; + + RAIILDAPString(char *Str) + : str(Str) + { + } + + ~RAIILDAPString() + { + ldap_memfree(str); + } + + operator char*() + { + return str; + } + + operator std::string() + { + return str; + } +}; + class ModuleLDAPAuth : public Module { std::string base; @@ -165,7 +190,8 @@ public: authpass = strdup(opassword.c_str()); cred.bv_val = authpass; cred.bv_len = opassword.length(); - if ((res = ldap_sasl_bind_s(conn, ldap_get_dn(conn, entry), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) == LDAP_SUCCESS) + RAIILDAPString DN(ldap_get_dn(conn, entry)); + if ((res = ldap_sasl_bind_s(conn, DN, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) == LDAP_SUCCESS) { free(authpass); ldap_msgfree(msg); |
