Fixed null pointer dereference in resolver (ticket #91). The cycle->new_log.file may not be set before config parsing finished if there are no error_log directive defined at global level. Fix is to copy it after config parsing. Patch by Roman Arutyunyan.
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 5a0ade7..5c51617 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c
@@ -189,11 +189,6 @@ uc->sockaddr = u.addrs->sockaddr; uc->socklen = u.addrs->socklen; uc->server = u.addrs->name; - - uc->log = cf->cycle->new_log; - uc->log.handler = ngx_resolver_log_error; - uc->log.data = uc; - uc->log.action = "resolving"; } return r; @@ -876,6 +871,12 @@ } if (uc->connection == NULL) { + + uc->log = *r->log; + uc->log.handler = ngx_resolver_log_error; + uc->log.data = uc; + uc->log.action = "resolving"; + if (ngx_udp_connect(uc) != NGX_OK) { return NGX_ERROR; }