Hey,
What is the proper method for deinitializing an LDAP * context if the binding fails?
Consider the following code:
ret = ldap_initialize(&ld, buf);
if (ret) {
ERR("ldap_initialize: %s: %s", buf, ldap_err2string(ret));
}
ret = ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
if (ret) {
ERR("ldap_set_option: %s", ldap_err2string(ret));
} else {
ret = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &v3);
if (ret) {
ERR("ldap_set_option: %s", ldap_err2string(ret));
} else {
if (my_ldap_bind_gssapi(ld, flags) == 0) {
return 0;
}
}
}
ldap_unbind_ext(lx->ld, NULL, NULL);
If the bind fails, the ldap_unbind_ext function asserts:
unbind.c:49: ldap_unbind_ext: Assertion `( (ld)->ld_options.ldo_valid == 0x2 )' failed.
Aborted
What am I doing wrong?