X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fopenldap.c;h=c060bdc037483cb8281cdddd93e91c347b819a48;hp=61eb62e3577eb508e0dd613bfd92570d374e4b42;hb=3179c85911babea7e51902d5d72c6fe1812af4d0;hpb=fd01cdd0546ccbbda7f4cf5db2d0ae28e1e770cd diff --git a/src/openldap.c b/src/openldap.c index 61eb62e3..c060bdc0 100644 --- a/src/openldap.c +++ b/src/openldap.c @@ -92,7 +92,8 @@ static int cldap_init_host(cldap_t *st) /* {{{ */ if (rc != LDAP_SUCCESS) { ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc)); st->state = 0; - ldap_unbind_ext_s(ld, NULL, NULL); + if (ld != NULL) + ldap_unbind_ext_s(ld, NULL, NULL); return (-1); } @@ -119,7 +120,8 @@ static int cldap_init_host(cldap_t *st) /* {{{ */ ERROR("openldap plugin: Failed to start tls on %s: %s", st->url, ldap_err2string(rc)); st->state = 0; - ldap_unbind_ext_s(st->ld, NULL, NULL); + if (st->ld != NULL) + ldap_unbind_ext_s(st->ld, NULL, NULL); return (-1); } } @@ -139,7 +141,8 @@ static int cldap_init_host(cldap_t *st) /* {{{ */ ERROR("openldap plugin: Failed to bind to %s: %s", st->url, ldap_err2string(rc)); st->state = 0; - ldap_unbind_ext_s(st->ld, NULL, NULL); + if (st->ld != NULL) + ldap_unbind_ext_s(st->ld, NULL, NULL); return (-1); } else { DEBUG("openldap plugin: Successfully connected to %s", st->url); @@ -221,7 +224,8 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */ ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc)); ldap_msgfree(result); st->state = 0; - ldap_unbind_ext_s(st->ld, NULL, NULL); + if (st->ld != NULL) + ldap_unbind_ext_s(st->ld, NULL, NULL); return (-1); }