From: "Hans Leidekker" <[EMAIL PROTECTED]> > > - 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;