Re: WLDAP32: improve error handling for the bind functions
From: "Hans Leidekker" <hans(a)it.vu.nl>
- credW = strAtoW( cred ); - if (!credW) return LDAP_NO_MEMORY; + if (dn) { + dnW = strAtoW( dn ); + if (!dnW) return LDAP_NO_MEMORY; + } + if (cred) { + credW = strAtoW( cred ); + if (!credW) return LDAP_NO_MEMORY; + }
This leaks memory, if credW fails to allocate. Something like this would work: + WCHAR *dnW = NULL, *credW = NULL; + int ret = LDAP_NO_MEMORY; + + if (dn) { + dnW = strAtoW( dn ); + if (!dnW) goto exit; + } + if (cred) { + credW = strAtoW( cred ); + if (!credW) goto exit; + } + ret = ldap_bindW( ld, dnW, credW, method ); + exit: + free dnW, credW + return ret;
participants (1)
-
Dimi Paun