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.
This commit is contained in:
Vladimir Homutov 2014-07-24 16:25:07 +04:00
parent 248baf4262
commit c54899ddfd

View File

@ -387,20 +387,22 @@ ngx_log_open_default(ngx_cycle_t *cycle)
return NGX_ERROR; return NGX_ERROR;
} }
log->log_level = NGX_LOG_ERR;
ngx_log_insert(&cycle->new_log, log);
} else { } else {
/* no error logs at all */ /* no error logs at all */
log = &cycle->new_log; 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); log->file = ngx_conf_open_file(cycle, &error_log);
if (log->file == NULL) { if (log->file == NULL) {
return NGX_ERROR; return NGX_ERROR;
} }
if (log != &cycle->new_log) {
ngx_log_insert(&cycle->new_log, log);
}
return NGX_OK; return NGX_OK;
} }