From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/wldap32/init.c | 50 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/dlls/wldap32/init.c b/dlls/wldap32/init.c index dcd20fea999..472bf2ffdbf 100644 --- a/dlls/wldap32/init.c +++ b/dlls/wldap32/init.c @@ -334,15 +334,17 @@ LDAP * CDECL ldap_initA( const PCHAR hostname, ULONG portnumber ) LDAP * CDECL ldap_initW( const PWCHAR hostname, ULONG portnumber ) { LDAP *ld = NULL; - char *hostnameU, *url = NULL; - WCHAR *hostnameW; + char *hostnameU = NULL, *url = NULL; + WCHAR *hostnameW = NULL;
TRACE( "(%s, %lu)\n", debugstr_w(hostname), portnumber );
- if (!(hostnameW = wcsdup( hostname ? hostname : L"localhost" ))) return NULL; - if (!(hostnameU = strWtoU( hostnameW ))) goto exit; - if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit; - + if (hostname) + { + if (!(hostnameW = wcsdup( hostname ))) return NULL; + if (!(hostnameU = strWtoU( hostnameW ))) goto exit; + if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit; + } ld = create_context( url ); exit: if (ld) @@ -378,15 +380,17 @@ LDAP * CDECL ldap_openA( char *hostname, ULONG portnumber ) LDAP * CDECL ldap_openW( WCHAR *hostname, ULONG portnumber ) { LDAP *ld = NULL; - char *hostnameU, *url = NULL; - WCHAR *hostnameW; + char *hostnameU = NULL, *url = NULL; + WCHAR *hostnameW = NULL;
TRACE( "(%s, %lu)\n", debugstr_w(hostname), portnumber );
- if (!(hostnameW = wcsdup( hostname ? hostname : L"localhost" ))) return NULL; - if (!(hostnameU = strWtoU( hostnameW ))) goto exit; - if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit; - + if (hostname) + { + if (!(hostnameW = wcsdup( hostname ))) return NULL; + if (!(hostnameU = strWtoU( hostnameW ))) goto exit; + if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit; + } ld = create_context( url ); exit: if (ld) @@ -422,20 +426,22 @@ LDAP * CDECL ldap_sslinitA( char *hostname, ULONG portnumber, int secure ) LDAP * CDECL ldap_sslinitW( WCHAR *hostname, ULONG portnumber, int secure ) { LDAP *ld = NULL; - char *hostnameU, *url = NULL; - WCHAR *hostnameW; + char *hostnameU = NULL, *url = NULL; + WCHAR *hostnameW = NULL;
TRACE( "(%s, %lu, %d)\n", debugstr_w(hostname), portnumber, secure );
- if (!(hostnameW = wcsdup( hostname ? hostname : L"localhost" ))) return NULL; - if (!(hostnameU = strWtoU( hostnameW ))) goto exit; - - if (secure) - url = urlify_hostnames( "ldaps://", hostnameU, portnumber ); - else - url = urlify_hostnames( "ldap://", hostnameU, portnumber ); - if (!url) goto exit; + if (hostname) + { + if (!(hostnameW = wcsdup( hostname ))) return NULL; + if (!(hostnameU = strWtoU( hostnameW ))) goto exit;
+ if (secure) + url = urlify_hostnames( "ldaps://", hostnameU, portnumber ); + else + url = urlify_hostnames( "ldap://", hostnameU, portnumber ); + if (!url) goto exit; + } ld = create_context( url ); exit: if (ld)