sasl_ssf_t              *ssf;
        sasl_conn_t             *ctx;
        sasl_interact_t *prompts = NULL;
-       struct berval   ccred;
+       struct berval   ccred = BER_BVNULL;
        int saslrc, rc;
        unsigned credlen;
 
                sasl_setprop( ctx, SASL_SEC_PROPS,
                        &ld->ld_options.ldo_sasl_secprops );
 
-               ccred.bv_val = NULL;
-               ccred.bv_len = 0;
                mech = NULL;
 
                do {
 
                        if( pmech == NULL && mech != NULL ) {
                                pmech = mech;
+                               *rmech = mech;
 
                                if( flags != LDAP_SASL_QUIET ) {
                                        fprintf(stderr,
 
                                if( res != LDAP_SUCCESS ) break;
                        }
-                       *rmech = mech;
                } while ( saslrc == SASL_INTERACT );
 
        } else {