]> git.sur5r.net Git - openldap/commitdiff
ld could be used uninitialized
authorHallvard Furuseth <hallvard@openldap.org>
Sun, 8 Nov 1998 03:01:51 +0000 (03:01 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Sun, 8 Nov 1998 03:01:51 +0000 (03:01 +0000)
clients/gopher/go500.c

index e9cb600ef8c9399a6f9a50ee5bd704b831da35e6..0f706498a7d926072a7b32c58e6604caacc2b6fc 100644 (file)
@@ -378,23 +378,21 @@ int       s;
 
        rewind(fp);
 
-       if ( *query != '~' && *query != '@' ) {
-               if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
-                       fprintf(fp,
-                           "0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
-                           LDAP_SERVER_DOWN, myhost, myport );
-                       fprintf( fp, ".\r\n" );
-                       rewind(fp);
-                       exit( 1 );
-               }
-
-               {
-                       int deref = GO500_DEREF;
-                       ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
-               }
+       if ( *query == '~' || *query == '@' ) {
+               ld = NULL;
+       } else if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+               fprintf(fp,
+                       "0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
+                       LDAP_SERVER_DOWN, myhost, myport );
+               fprintf( fp, ".\r\n" );
+               rewind(fp);
+               exit( 1 );
+       } else {
+               int deref = GO500_DEREF;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 
-               if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED ))
-                   != LDAP_SUCCESS ) {
+               rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED );
+               if ( rc != LDAP_SUCCESS ) {
                        fprintf(fp,
                            "0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
                            rc, myhost, myport );
@@ -428,7 +426,8 @@ int s;
 
        fprintf( fp, ".\r\n" );
        rewind(fp);
-       ldap_unbind( ld );
+       if ( ld )
+               ldap_unbind( ld );
 
        exit( 1 );
        /* NOT REACHED */