src/http/ngx_http_core_module.c:1236: error: Null Dereference
  pointer `name` last assigned on line 1188 could be null and is dereferenced by call to `memcpy()` at line 1236, column 13.

src/http/ngx_http_core_module.c:1161:1: start of procedure ngx_http_core_try_files_phase()
1159. 
1160. 
1161. ngx_int_t
      ^
1162. ngx_http_core_try_files_phase(ngx_http_request_t *r,
1163.     ngx_http_phase_handler_t *ph)

src/http/ngx_http_core_module.c:1179:5: 
1177.                    "try files phase: %ui", r->phase_handler);
1178. 
1179.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
          ^
1180. 
1181.     if (clcf->try_files == NULL) {

src/http/ngx_http_core_module.c:1181:9: Taking false branch
1179.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1180. 
1181.     if (clcf->try_files == NULL) {
              ^
1182.         r->phase_handler++;
1183.         return NGX_AGAIN;

src/http/ngx_http_core_module.c:1186:5: 
1184.     }
1185. 
1186.     allocated = 0;
          ^
1187.     root = 0;
1188.     name = NULL;

src/http/ngx_http_core_module.c:1187:5: 
1185. 
1186.     allocated = 0;
1187.     root = 0;
          ^
1188.     name = NULL;
1189.     /* suppress MSVC warning */

src/http/ngx_http_core_module.c:1188:5: 
1186.     allocated = 0;
1187.     root = 0;
1188.     name = NULL;
          ^
1189.     /* suppress MSVC warning */
1190.     path.data = NULL;

src/http/ngx_http_core_module.c:1190:5: 
1188.     name = NULL;
1189.     /* suppress MSVC warning */
1190.     path.data = NULL;
          ^
1191. 
1192.     tf = clcf->try_files;

src/http/ngx_http_core_module.c:1192:5: 
1190.     path.data = NULL;
1191. 
1192.     tf = clcf->try_files;
          ^
1193. 
1194.     alias = clcf->alias;

src/http/ngx_http_core_module.c:1194:5: 
1192.     tf = clcf->try_files;
1193. 
1194.     alias = clcf->alias;
          ^
1195. 
1196.     for ( ;; ) {

src/http/ngx_http_core_module.c:1351:5: Loop condition is true. Entering loop body
1349.         r->phase_handler++;
1350.         return NGX_AGAIN;
1351.     }
          ^
1352. 
1353.     /* not reached */

src/http/ngx_http_core_module.c:1198:13: Taking false branch
1196.     for ( ;; ) {
1197. 
1198.         if (tf->lengths) {
                  ^
1199.             ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
1200. 

src/http/ngx_http_core_module.c:1213:13: 
1211. 
1212.         } else {
1213.             len = tf->name.len;
                  ^
1214.         }
1215. 

src/http/ngx_http_core_module.c:1217:19: Condition is true
1215. 
1216.         /* 16 bytes are preallocation */
1217.         reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;
                        ^
1218. 
1219.         if (reserve > allocated) {

src/http/ngx_http_core_module.c:1217:9: 
1215. 
1216.         /* 16 bytes are preallocation */
1217.         reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;
              ^
1218. 
1219.         if (reserve > allocated) {

src/http/ngx_http_core_module.c:1219:13: Taking false branch
1217.         reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;
1218. 
1219.         if (reserve > allocated) {
                  ^
1220. 
1221.             /* we just need to allocate path and to copy a root */

src/http/ngx_http_core_module.c:1232:13: Taking true branch
1230.          }
1231. 
1232.         if (tf->values == NULL) {
                  ^
1233. 
1234.             /* tf->name.len includes the terminating '\0' */

src/http/ngx_http_core_module.c:1236:13: 
1234.             /* tf->name.len includes the terminating '\0' */
1235. 
1236.             ngx_memcpy(name, tf->name.data, tf->name.len);
                  ^
1237. 
1238.             path.len = (name + tf->name.len - 1) - path.data;

ngx_int_t
ngx_http_core_try_files_phase(ngx_http_request_t *r,
    ngx_http_phase_handler_t *ph)
{
    size_t                        len, root, alias, reserve, allocated;
    u_char                       *p, *name;
    ngx_str_t                     path, args;
    ngx_uint_t                    test_dir;
    ngx_http_try_file_t          *tf;
    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_script_len_code_pt   lcode;
    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                   "try files phase: %ui", r->phase_handler);
    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
    if (clcf->try_files == NULL) {
        r->phase_handler++;
        return NGX_AGAIN;
    }
    allocated = 0;
    root = 0;
    name = NULL;
    path.data = NULL;
    tf = clcf->try_files;
    alias = clcf->alias;
    for ( ;; ) {
        if (tf->lengths) {
            ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
            e.ip = tf->lengths->elts;
            e.request = r;
            len = 1;
            while (*(uintptr_t *) e.ip) {
                lcode = *(ngx_http_script_len_code_pt *) e.ip;
                len += lcode(&e);
            }
        } else {
            len = tf->name.len;
        }
        reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;
        if (reserve > allocated) {
            if (ngx_http_map_uri_to_path(r, &path, &root, reserve) == NULL) {
                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                return NGX_OK;
            }
            name = path.data + root;
            allocated = path.len - root - (r->uri.len - alias);
         }
        if (tf->values == NULL) {
            ngx_memcpy(name, tf->name.data, tf->name.len);
            path.len = (name + tf->name.len - 1) - path.data;
        } else {
            e.ip = tf->values->elts;
            e.pos = name;
            e.flushed = 1;
            while (*(uintptr_t *) e.ip) {
                code = *(ngx_http_script_code_pt *) e.ip;
                code((ngx_http_script_engine_t *) &e);
            }
            path.len = e.pos - path.data;
            *e.pos = '\0';
            if (alias && ngx_strncmp(name, clcf->name.data, alias) == 0) {
                ngx_memmove(name, name + alias, len - alias);
                path.len -= alias;
            }
        }
        test_dir = tf->test_dir;
        tf++;
        ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                       "trying to use %s: \"%s\" \"%s\"",
                       test_dir ? "dir" : "file", name, path.data);
        if (tf->lengths == NULL && tf->name.len == 0) {
            if (tf->code) {
                ngx_http_finalize_request(r, tf->code);
                return NGX_OK;
            }
            path.len -= root;
            path.data += root;
            if (path.data[0] == '@') {
                (void) ngx_http_named_location(r, &path);
            } else {
                ngx_http_split_args(r, &path, &args);
                (void) ngx_http_internal_redirect(r, &path, &args);
            }
            ngx_http_finalize_request(r, NGX_DONE);
            return NGX_OK;
        }
        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)
        {
            if (of.err != NGX_ENOENT
                && of.err != NGX_ENOTDIR
                && of.err != NGX_ENAMETOOLONG)
            {
                ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
                              "%s \"%s\" failed", of.failed, path.data);
            }
            continue;
        }
        if (of.is_dir && !test_dir) {
            continue;
        }
        path.len -= root;
        path.data += root;
        if (!alias) {
            r->uri = path;
#if (NGX_PCRE)
        } else if (clcf->regex) {
            if (!test_dir) {
                r->uri = path;
                r->add_uri_to_alias = 1;
            }
#endif
        } else {
            r->uri.len = alias + path.len;
            r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
            if (r->uri.data == NULL) {
                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                return NGX_OK;
            }
            p = ngx_copy(r->uri.data, clcf->name.data, alias);
            ngx_memcpy(p, name, path.len);
        }
        ngx_http_set_exten(r);
        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                       "try file uri: \"%V\"", &r->uri);
        r->phase_handler++;
        return NGX_AGAIN;
    }
}
['ngx_int_t\nngx_http_core_try_files_phase(ngx_http_request_t *r,\n    ngx_http_phase_handler_t *ph)\n{\n    size_t                        len, root, alias, reserve, allocated;\n    u_char                       *p, *name;\n    ngx_str_t                     path, args;\n    ngx_uint_t                    test_dir;\n    ngx_http_try_file_t          *tf;\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_script_len_code_pt   lcode;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "try files phase: %ui", r->phase_handler);\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->try_files == NULL) {\n        r->phase_handler++;\n        return NGX_AGAIN;\n    }\n    allocated = 0;\n    root = 0;\n    name = NULL;\n    path.data = NULL;\n    tf = clcf->try_files;\n    alias = clcf->alias;\n    for ( ;; ) {\n        if (tf->lengths) {\n            ngx_memzero(&e, sizeof(ngx_http_script_engine_t));\n            e.ip = tf->lengths->elts;\n            e.request = r;\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        } else {\n            len = tf->name.len;\n        }\n        reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;\n        if (reserve > allocated) {\n            if (ngx_http_map_uri_to_path(r, &path, &root, reserve) == NULL) {\n                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return NGX_OK;\n            }\n            name = path.data + root;\n            allocated = path.len - root - (r->uri.len - alias);\n         }\n        if (tf->values == NULL) {\n            ngx_memcpy(name, tf->name.data, tf->name.len);\n            path.len = (name + tf->name.len - 1) - path.data;\n        } else {\n            e.ip = tf->values->elts;\n            e.pos = name;\n            e.flushed = 1;\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            path.len = e.pos - path.data;\n            *e.pos = \'\\0\';\n            if (alias && ngx_strncmp(name, clcf->name.data, alias) == 0) {\n                ngx_memmove(name, name + alias, len - alias);\n                path.len -= alias;\n            }\n        }\n        test_dir = tf->test_dir;\n        tf++;\n        ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "trying to use %s: \\"%s\\" \\"%s\\"",\n                       test_dir ? "dir" : "file", name, path.data);\n        if (tf->lengths == NULL && tf->name.len == 0) {\n            if (tf->code) {\n                ngx_http_finalize_request(r, tf->code);\n                return NGX_OK;\n            }\n            path.len -= root;\n            path.data += root;\n            if (path.data[0] == \'@\') {\n                (void) ngx_http_named_location(r, &path);\n            } else {\n                ngx_http_split_args(r, &path, &args);\n                (void) ngx_http_internal_redirect(r, &path, &args);\n            }\n            ngx_http_finalize_request(r, NGX_DONE);\n            return NGX_OK;\n        }\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            if (of.err != NGX_ENOENT\n                && of.err != NGX_ENOTDIR\n                && of.err != NGX_ENAMETOOLONG)\n            {\n                ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,\n                              "%s \\"%s\\" failed", of.failed, path.data);\n            }\n            continue;\n        }\n        if (of.is_dir && !test_dir) {\n            continue;\n        }\n        path.len -= root;\n        path.data += root;\n        if (!alias) {\n            r->uri = path;\n#if (NGX_PCRE)\n        } else if (clcf->regex) {\n            if (!test_dir) {\n                r->uri = path;\n                r->add_uri_to_alias = 1;\n            }\n#endif\n        } else {\n            r->uri.len = alias + path.len;\n            r->uri.data = ngx_pnalloc(r->pool, r->uri.len);\n            if (r->uri.data == NULL) {\n                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return NGX_OK;\n            }\n            p = ngx_copy(r->uri.data, clcf->name.data, alias);\n            ngx_memcpy(p, name, path.len);\n        }\n        ngx_http_set_exten(r);\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "try file uri: \\"%V\\"", &r->uri);\n        r->phase_handler++;\n        return NGX_AGAIN;\n    }\n}']