X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fopenldap.c;h=50757db8ac513017c954a690cd227b0e2291ea02;hb=ca89ee257db233a0512c73b6d8353b1aa86e3e8a;hp=5269e5f2a2d715cf8ee44527f2434e43be58691a;hpb=e37e426d6646d6ff99834461f00c3dd79fa85d43;p=collectd.git diff --git a/src/openldap.c b/src/openldap.c index 5269e5f2..50757db8 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); @@ -214,7 +217,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); }