From 5cb46a08e7b54828a2d57975ffedbb302a45f6d3 Mon Sep 17 00:00:00 2001 From: Jiri Hruska Date: Tue, 3 Sep 2013 19:12:29 +0200 Subject: [PATCH] Do not crash on startup when no servers have been defined --- ngx_http_auth_ldap_module.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ngx_http_auth_ldap_module.c b/ngx_http_auth_ldap_module.c index ab6e252..fabfded 100644 --- a/ngx_http_auth_ldap_module.c +++ b/ngx_http_auth_ldap_module.c @@ -1314,6 +1314,11 @@ ngx_http_auth_ldap_init_connections(ngx_cycle_t *cycle) ngx_int_t rc; int option; + halmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_auth_ldap_module); + if (halmcf == NULL || halmcf->servers == NULL) { + return NGX_OK; + } + option = LDAP_VERSION3; rc = ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &option); @@ -1324,7 +1329,6 @@ ngx_http_auth_ldap_init_connections(ngx_cycle_t *cycle) rc, ldap_err2string(rc)); } - halmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_auth_ldap_module); for (i = 0; i < halmcf->servers->nelts; i++) { server = &((ngx_http_auth_ldap_server_t *) halmcf->servers->elts)[i]; ngx_queue_init(&server->free_connections);