# HG changeset patch # User Vladimir Homutov # Date 1406204707 -14400 # Node ID c3b08217f2a24f4531e578082dff498d85818cf0 # Parent 9de5820bb3e04d7e21727b472a15831ec0b2be1d Core: fixed default log initialization. The ngx_log_insert() function may invalidate pointer passed to it, so make sure to don't use it after the ngx_log_insert() call. diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -387,20 +387,22 @@ ngx_log_open_default(ngx_cycle_t *cycle) return NGX_ERROR; } - log->log_level = NGX_LOG_ERR; - ngx_log_insert(&cycle->new_log, log); - } else { /* no error logs at all */ log = &cycle->new_log; - log->log_level = NGX_LOG_ERR; } + log->log_level = NGX_LOG_ERR; + log->file = ngx_conf_open_file(cycle, &error_log); if (log->file == NULL) { return NGX_ERROR; } + if (log != &cycle->new_log) { + ngx_log_insert(&cycle->new_log, log); + } + return NGX_OK; }