src/http/modules/ngx_http_index_module.c:188: error: Null Dereference
  pointer `name` last assigned on line 125 could be null and is dereferenced at line 188, column 17.

src/http/modules/ngx_http_index_module.c:95:1: start of procedure ngx_http_index_handler()
93.  */
94. 
95. static ngx_int_t
    ^
96. ngx_http_index_handler(ngx_http_request_t *r)
97. {

src/http/modules/ngx_http_index_module.c:111:9: Taking false branch
109.     ngx_http_script_len_code_pt   lcode;
110. 
111.     if (r->uri.data[r->uri.len - 1] != '/') {
             ^
112.         return NGX_DECLINED;
113.     }

src/http/modules/ngx_http_index_module.c:115:11: Taking false branch
113.     }
114. 
115.     if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
               ^
116.         return NGX_DECLINED;
117.     }

src/http/modules/ngx_http_index_module.c:119:5: 
117.     }
118. 
119.     ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);
         ^
120.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
121. 

src/http/modules/ngx_http_index_module.c:120:5: 
118. 
119.     ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);
120.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
         ^
121. 
122.     allocated = 0;

src/http/modules/ngx_http_index_module.c:122:5: 
120.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
121. 
122.     allocated = 0;
         ^
123.     root = 0;
124.     dir_tested = 0;

src/http/modules/ngx_http_index_module.c:123:5: 
121. 
122.     allocated = 0;
123.     root = 0;
         ^
124.     dir_tested = 0;
125.     name = NULL;

src/http/modules/ngx_http_index_module.c:124:5: 
122.     allocated = 0;
123.     root = 0;
124.     dir_tested = 0;
         ^
125.     name = NULL;
126.     /* suppress MSVC warning */

src/http/modules/ngx_http_index_module.c:125:5: 
123.     root = 0;
124.     dir_tested = 0;
125.     name = NULL;
         ^
126.     /* suppress MSVC warning */
127.     path.data = NULL;

src/http/modules/ngx_http_index_module.c:127:5: 
125.     name = NULL;
126.     /* suppress MSVC warning */
127.     path.data = NULL;
         ^
128. 
129.     index = ilcf->indices->elts;

src/http/modules/ngx_http_index_module.c:129:5: 
127.     path.data = NULL;
128. 
129.     index = ilcf->indices->elts;
         ^
130.     for (i = 0; i < ilcf->indices->nelts; i++) {
131. 

src/http/modules/ngx_http_index_module.c:130:10: 
128. 
129.     index = ilcf->indices->elts;
130.     for (i = 0; i < ilcf->indices->nelts; i++) {
              ^
131. 
132.         if (index[i].lengths == NULL) {

src/http/modules/ngx_http_index_module.c:130:17: Loop condition is true. Entering loop body
128. 
129.     index = ilcf->indices->elts;
130.     for (i = 0; i < ilcf->indices->nelts; i++) {
                     ^
131. 
132.         if (index[i].lengths == NULL) {

src/http/modules/ngx_http_index_module.c:132:13: Taking true branch
130.     for (i = 0; i < ilcf->indices->nelts; i++) {
131. 
132.         if (index[i].lengths == NULL) {
                 ^
133. 
134.             if (index[i].name.data[0] == '/') {

src/http/modules/ngx_http_index_module.c:134:17: Taking false branch
132.         if (index[i].lengths == NULL) {
133. 
134.             if (index[i].name.data[0] == '/') {
                     ^
135.                 return ngx_http_internal_redirect(r, &index[i].name, &r->args);
136.             }

src/http/modules/ngx_http_index_module.c:138:13: 
136.             }
137. 
138.             reserve = ilcf->max_index_len;
                 ^
139.             len = index[i].name.len;
140. 

src/http/modules/ngx_http_index_module.c:139:13: 
137. 
138.             reserve = ilcf->max_index_len;
139.             len = index[i].name.len;
                 ^
140. 
141.         } else {

src/http/modules/ngx_http_index_module.c:161:13: Taking false branch
159.         }
160. 
161.         if (reserve > allocated) {
                 ^
162. 
163.             name = ngx_http_map_uri_to_path(r, &path, &root, reserve);

src/http/modules/ngx_http_index_module.c:171:13: Taking false branch
169.         }
170. 
171.         if (index[i].values == NULL) {
                 ^
172. 
173.             /* index[i].name.len includes the terminating '\0' */

src/http/modules/ngx_http_index_module.c:180:13: 
178. 
179.         } else {
180.             e.ip = index[i].values->elts;
                 ^
181.             e.pos = name;
182. 

src/http/modules/ngx_http_index_module.c:181:13: 
179.         } else {
180.             e.ip = index[i].values->elts;
181.             e.pos = name;
                 ^
182. 
183.             while (*(uintptr_t *) e.ip) {

src/http/modules/ngx_http_index_module.c:183:20: Loop condition is true. Entering loop body
181.             e.pos = name;
182. 
183.             while (*(uintptr_t *) e.ip) {
                        ^
184.                 code = *(ngx_http_script_code_pt *) e.ip;
185.                 code((ngx_http_script_engine_t *) &e);

src/http/modules/ngx_http_index_module.c:184:17: 
182. 
183.             while (*(uintptr_t *) e.ip) {
184.                 code = *(ngx_http_script_code_pt *) e.ip;
                     ^
185.                 code((ngx_http_script_engine_t *) &e);
186.             }

src/http/modules/ngx_http_index_module.c:185:17: Skipping __function_pointer__(): unresolved function pointer
183.             while (*(uintptr_t *) e.ip) {
184.                 code = *(ngx_http_script_code_pt *) e.ip;
185.                 code((ngx_http_script_engine_t *) &e);
                     ^
186.             }
187. 

src/http/modules/ngx_http_index_module.c:183:20: Loop condition is false. Leaving loop
181.             e.pos = name;
182. 
183.             while (*(uintptr_t *) e.ip) {
                        ^
184.                 code = *(ngx_http_script_code_pt *) e.ip;
185.                 code((ngx_http_script_engine_t *) &e);

src/http/modules/ngx_http_index_module.c:188:17: 
186.             }
187. 
188.             if (*name == '/') {
                     ^
189.                 uri.len = len - 1;
190.                 uri.data = name;

static ngx_int_t
ngx_http_index_handler(ngx_http_request_t *r)
{
    u_char                       *p, *name;
    size_t                        len, root, reserve, allocated;
    ngx_int_t                     rc;
    ngx_str_t                     path, uri;
    ngx_uint_t                    i, dir_tested;
    ngx_http_index_t             *index;
    ngx_open_file_info_t          of;
    ngx_http_script_code_pt       code;
    ngx_http_script_engine_t      e;
    ngx_http_core_loc_conf_t     *clcf;
    ngx_http_index_loc_conf_t    *ilcf;
    ngx_http_script_len_code_pt   lcode;
    if (r->uri.data[r->uri.len - 1] != '/') {
        return NGX_DECLINED;
    }
    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
        return NGX_DECLINED;
    }
    ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);
    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
    allocated = 0;
    root = 0;
    dir_tested = 0;
    name = NULL;
    path.data = NULL;
    index = ilcf->indices->elts;
    for (i = 0; i < ilcf->indices->nelts; i++) {
        if (index[i].lengths == NULL) {
            if (index[i].name.data[0] == '/') {
                return ngx_http_internal_redirect(r, &index[i].name, &r->args);
            }
            reserve = ilcf->max_index_len;
            len = index[i].name.len;
        } else {
            ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
            e.ip = index[i].lengths->elts;
            e.request = r;
            e.flushed = 1;
            len = 1;
            while (*(uintptr_t *) e.ip) {
                lcode = *(ngx_http_script_len_code_pt *) e.ip;
                len += lcode(&e);
            }
            reserve = len + 16;
        }
        if (reserve > allocated) {
            name = ngx_http_map_uri_to_path(r, &path, &root, reserve);
            if (name == NULL) {
                return NGX_ERROR;
            }
            allocated = path.data + path.len - name;
        }
        if (index[i].values == NULL) {
            ngx_memcpy(name, index[i].name.data, index[i].name.len);
            path.len = (name + index[i].name.len - 1) - path.data;
        } else {
            e.ip = index[i].values->elts;
            e.pos = name;
            while (*(uintptr_t *) e.ip) {
                code = *(ngx_http_script_code_pt *) e.ip;
                code((ngx_http_script_engine_t *) &e);
            }
            if (*name == '/') {
                uri.len = len - 1;
                uri.data = name;
                return ngx_http_internal_redirect(r, &uri, &r->args);
            }
            path.len = e.pos - path.data;
            *e.pos = '\0';
        }
        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                       "open index \"%V\"", &path);
        ngx_memzero(&of, sizeof(ngx_open_file_info_t));
        of.read_ahead = clcf->read_ahead;
        of.directio = clcf->directio;
        of.valid = clcf->open_file_cache_valid;
        of.min_uses = clcf->open_file_cache_min_uses;
        of.test_only = 1;
        of.errors = clcf->open_file_cache_errors;
        of.events = clcf->open_file_cache_events;
        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;
            }
            if (of.err == NGX_ENOTDIR
                || of.err == NGX_ENAMETOOLONG
                || of.err == NGX_EACCES)
            {
                return ngx_http_index_error(r, clcf, path.data, of.err);
            }
            if (!dir_tested) {
                rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1);
                if (rc != NGX_OK) {
                    return rc;
                }
                dir_tested = 1;
            }
            if (of.err == NGX_ENOENT) {
                continue;
            }
            ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
                          "%s \"%s\" failed", of.failed, path.data);
            return NGX_HTTP_INTERNAL_SERVER_ERROR;
        }
        uri.len = r->uri.len + len - 1;
        if (!clcf->alias) {
            uri.data = path.data + root;
        } else {
            uri.data = ngx_pnalloc(r->pool, uri.len);
            if (uri.data == NULL) {
                return NGX_HTTP_INTERNAL_SERVER_ERROR;
            }
            p = ngx_copy(uri.data, r->uri.data, r->uri.len);
            ngx_memcpy(p, name, len - 1);
        }
        return ngx_http_internal_redirect(r, &uri, &r->args);
    }
    return NGX_DECLINED;
}
['static ngx_int_t\nngx_http_index_handler(ngx_http_request_t *r)\n{\n    u_char                       *p, *name;\n    size_t                        len, root, reserve, allocated;\n    ngx_int_t                     rc;\n    ngx_str_t                     path, uri;\n    ngx_uint_t                    i, dir_tested;\n    ngx_http_index_t             *index;\n    ngx_open_file_info_t          of;\n    ngx_http_script_code_pt       code;\n    ngx_http_script_engine_t      e;\n    ngx_http_core_loc_conf_t     *clcf;\n    ngx_http_index_loc_conf_t    *ilcf;\n    ngx_http_script_len_code_pt   lcode;\n    if (r->uri.data[r->uri.len - 1] != \'/\') {\n        return NGX_DECLINED;\n    }\n    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {\n        return NGX_DECLINED;\n    }\n    ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    allocated = 0;\n    root = 0;\n    dir_tested = 0;\n    name = NULL;\n    path.data = NULL;\n    index = ilcf->indices->elts;\n    for (i = 0; i < ilcf->indices->nelts; i++) {\n        if (index[i].lengths == NULL) {\n            if (index[i].name.data[0] == \'/\') {\n                return ngx_http_internal_redirect(r, &index[i].name, &r->args);\n            }\n            reserve = ilcf->max_index_len;\n            len = index[i].name.len;\n        } else {\n            ngx_memzero(&e, sizeof(ngx_http_script_engine_t));\n            e.ip = index[i].lengths->elts;\n            e.request = r;\n            e.flushed = 1;\n            len = 1;\n            while (*(uintptr_t *) e.ip) {\n                lcode = *(ngx_http_script_len_code_pt *) e.ip;\n                len += lcode(&e);\n            }\n            reserve = len + 16;\n        }\n        if (reserve > allocated) {\n            name = ngx_http_map_uri_to_path(r, &path, &root, reserve);\n            if (name == NULL) {\n                return NGX_ERROR;\n            }\n            allocated = path.data + path.len - name;\n        }\n        if (index[i].values == NULL) {\n            ngx_memcpy(name, index[i].name.data, index[i].name.len);\n            path.len = (name + index[i].name.len - 1) - path.data;\n        } else {\n            e.ip = index[i].values->elts;\n            e.pos = name;\n            while (*(uintptr_t *) e.ip) {\n                code = *(ngx_http_script_code_pt *) e.ip;\n                code((ngx_http_script_engine_t *) &e);\n            }\n            if (*name == \'/\') {\n                uri.len = len - 1;\n                uri.data = name;\n                return ngx_http_internal_redirect(r, &uri, &r->args);\n            }\n            path.len = e.pos - path.data;\n            *e.pos = \'\\0\';\n        }\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "open index \\"%V\\"", &path);\n        ngx_memzero(&of, sizeof(ngx_open_file_info_t));\n        of.read_ahead = clcf->read_ahead;\n        of.directio = clcf->directio;\n        of.valid = clcf->open_file_cache_valid;\n        of.min_uses = clcf->open_file_cache_min_uses;\n        of.test_only = 1;\n        of.errors = clcf->open_file_cache_errors;\n        of.events = clcf->open_file_cache_events;\n        if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)\n            != NGX_OK)\n        {\n            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,\n                           "%s \\"%s\\" failed", of.failed, path.data);\n            if (of.err == 0) {\n                return NGX_HTTP_INTERNAL_SERVER_ERROR;\n            }\n            if (of.err == NGX_ENOTDIR\n                || of.err == NGX_ENAMETOOLONG\n                || of.err == NGX_EACCES)\n            {\n                return ngx_http_index_error(r, clcf, path.data, of.err);\n            }\n            if (!dir_tested) {\n                rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1);\n                if (rc != NGX_OK) {\n                    return rc;\n                }\n                dir_tested = 1;\n            }\n            if (of.err == NGX_ENOENT) {\n                continue;\n            }\n            ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,\n                          "%s \\"%s\\" failed", of.failed, path.data);\n            return NGX_HTTP_INTERNAL_SERVER_ERROR;\n        }\n        uri.len = r->uri.len + len - 1;\n        if (!clcf->alias) {\n            uri.data = path.data + root;\n        } else {\n            uri.data = ngx_pnalloc(r->pool, uri.len);\n            if (uri.data == NULL) {\n                return NGX_HTTP_INTERNAL_SERVER_ERROR;\n            }\n            p = ngx_copy(uri.data, r->uri.data, r->uri.len);\n            ngx_memcpy(p, name, len - 1);\n        }\n        return ngx_http_internal_redirect(r, &uri, &r->args);\n    }\n    return NGX_DECLINED;\n}']