diff src/http/modules/ngx_http_index_module.c @ 6948:3fb9b5eb75c0

Fixed ngx_open_cached_file() error handling. If of.err is 0, it means that there was a memory allocation error and no further logging and/or processing is needed. The of.failed string can be only accessed if of.err is not 0.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 28 Mar 2017 14:21:38 +0300
parents 3d50d86f3572
children e55e28e6998f
line wrap: on
line diff
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -217,13 +217,13 @@ ngx_http_index_handler(ngx_http_request_
         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
             != NGX_OK)
         {
-            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
-                           "%s \"%s\" failed", of.failed, path.data);
-
             if (of.err == 0) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
 
+            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
+                           "%s \"%s\" failed", of.failed, path.data);
+
 #if (NGX_HAVE_OPENAT)
             if (of.err == NGX_EMLINK
                 || of.err == NGX_ELOOP)