src/core/nginx.c:341: error: Buffer Overrun S2
  Offset: `ngx_core_module.index` Size: [0, +oo].

src/core/nginx.c:198:1: <Offset trace>
196. 
197. 
198. int ngx_cdecl
     ^
199. main(int argc, char *const *argv)
200. {

src/core/nginx.c:198:1: Global `ngx_core_module.index`
196. 
197. 
198. int ngx_cdecl
     ^
199. main(int argc, char *const *argv)
200. {

src/core/nginx.c:317:13: <Length trace>
315.     }
316. 
317.     cycle = ngx_init_cycle(&init_cycle);
                 ^
318.     if (cycle == NULL) {
319.         if (ngx_test_config) {

src/core/nginx.c:317:13: Call
315.     }
316. 
317.     cycle = ngx_init_cycle(&init_cycle);
                 ^
318.     if (cycle == NULL) {
319.         if (ngx_test_config) {

src/core/ngx_cycle.c:40:1: Global `ngx_max_module`
  38. 
  39. 
  40. ngx_cycle_t *
      ^
  41. ngx_init_cycle(ngx_cycle_t *old_cycle)
  42. {

src/core/ngx_cycle.c:183:23: Call
  181. 
  182. 
  183.     cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));
                             ^
  184.     if (cycle->conf_ctx == NULL) {
  185.         ngx_destroy_pool(pool);

src/core/ngx_palloc.c:299:1: Parameter `size`
    297. 
    298. 
    299. void *
         ^
    300. ngx_pcalloc(ngx_pool_t *pool, size_t size)
    301. {

src/core/ngx_palloc.c:304:9: Call
    302.     void *p;
    303. 
    304.     p = ngx_palloc(pool, size);
                 ^
    305.     if (p) {
    306.         ngx_memzero(p, size);

src/core/ngx_palloc.c:126:13: Assignment
      124. 
      125.         do {
      126.             m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);
                       ^
      127. 
      128.             if ((size_t) (p->d.end - m) >= size) {

src/core/ngx_palloc.c:131:17: Assignment
      129.                 p->d.last = m + size;
      130. 
      131.                 return m;
                           ^
      132.             }
      133. 

src/core/ngx_palloc.c:304:5: Assignment
    302.     void *p;
    303. 
    304.     p = ngx_palloc(pool, size);
             ^
    305.     if (p) {
    306.         ngx_memzero(p, size);

src/core/ngx_palloc.c:309:5: Assignment
    307.     }
    308. 
    309.     return p;
             ^
    310. }
    311. 

src/core/ngx_cycle.c:183:5: Assignment
  181. 
  182. 
  183.     cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));
           ^
  184.     if (cycle->conf_ctx == NULL) {
  185.         ngx_destroy_pool(pool);

src/core/nginx.c:341:31: Array access: Offset: ngx_core_module.index Size: [0, +oo]
339.     ngx_cycle = cycle;
340. 
341.     ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
                                   ^
342. 
343.     if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) {

int ngx_cdecl
main(int argc, char *const *argv)
{
    ngx_int_t         i;
    ngx_log_t        *log;
    ngx_cycle_t      *cycle, init_cycle;
    ngx_core_conf_t  *ccf;
    if (ngx_get_options(argc, argv) != NGX_OK) {
        return 1;
    }
    if (ngx_show_version) {
        ngx_log_stderr(0, "nginx version: " NGINX_VER);
        if (ngx_show_help) {
            ngx_log_stderr(0,
                "Usage: nginx [-?hvVt] [-s signal] [-c filename] "
                             "[-p prefix] [-g directives]" CRLF CRLF
                "Options:" CRLF
                "  -?,-h         : this help" CRLF
                "  -v            : show version and exit" CRLF
                "  -V            : show version and configure options then exit"
                                   CRLF
                "  -t            : test configuration and exit" CRLF
                "  -s signal     : send signal to a master process: "
                                   "stop, quit, reopen, reload" CRLF
#ifdef NGX_PREFIX
                "  -p prefix     : set prefix path (default: "
                                   NGX_PREFIX ")" CRLF
#else
                "  -p prefix     : set prefix path (default: NONE)" CRLF
#endif
                "  -c filename   : set configuration file (default: "
                                   NGX_CONF_PATH ")" CRLF
                "  -g directives : set global directives out of configuration "
                                   "file" CRLF
                );
        }
        if (ngx_show_configure) {
#ifdef NGX_COMPILER
            ngx_log_stderr(0, "built by " NGX_COMPILER);
#endif
            ngx_log_stderr(0, "configure arguments:" NGX_CONFIGURE);
        }
        if (!ngx_test_config) {
            return 0;
        }
    }
#if (NGX_FREEBSD)
    ngx_debug_init();
#endif
      ngx_max_sockets = -1;
    ngx_time_init();
#if (NGX_PCRE)
    ngx_regex_init();
#endif
    ngx_pid = ngx_getpid();
    log = ngx_log_init(ngx_prefix);
    if (log == NULL) {
        return 1;
    }
#if (NGX_OPENSSL)
    ngx_ssl_init(log);
#endif
    ngx_memzero(&init_cycle, sizeof(ngx_cycle_t));
    init_cycle.log = log;
    ngx_cycle = &init_cycle;
    init_cycle.pool = ngx_create_pool(1024, log);
    if (init_cycle.pool == NULL) {
        return 1;
    }
    if (ngx_save_argv(&init_cycle, argc, argv) != NGX_OK) {
        return 1;
    }
    if (ngx_process_options(&init_cycle) != NGX_OK) {
        return 1;
    }
    if (ngx_os_init(log) != NGX_OK) {
        return 1;
    }
    if (ngx_crc32_table_init() != NGX_OK) {
        return 1;
    }
    if (ngx_add_inherited_sockets(&init_cycle) != NGX_OK) {
        return 1;
    }
    ngx_max_module = 0;
    for (i = 0; ngx_modules[i]; i++) {
        ngx_modules[i]->index = ngx_max_module++;
    }
    cycle = ngx_init_cycle(&init_cycle);
    if (cycle == NULL) {
        if (ngx_test_config) {
            ngx_log_stderr(0, "configuration file %s test failed",
                           init_cycle.conf_file.data);
        }
        return 1;
    }
    if (ngx_test_config) {
        ngx_log_stderr(0, "configuration file %s test is successful",
                       cycle->conf_file.data);
        return 0;
    }
    if (ngx_signal) {
        return ngx_signal_process(cycle, ngx_signal);
    }
    ngx_os_status(cycle->log);
    ngx_cycle = cycle;
    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
    if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) {
        ngx_process = NGX_PROCESS_MASTER;
    }
#if !(NGX_WIN32)
    if (ngx_init_signals(cycle->log) != NGX_OK) {
        return 1;
    }
    if (!ngx_inherited && ccf->daemon) {
        if (ngx_daemon(cycle->log) != NGX_OK) {
            return 1;
        }
        ngx_daemonized = 1;
    }
#endif
    if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {
        return 1;
    }
    if (cycle->log->file->fd != ngx_stderr) {
        if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                          ngx_set_stderr_n " failed");
            return 1;
        }
    }
    ngx_use_stderr = 0;
    if (ngx_process == NGX_PROCESS_SINGLE) {
        ngx_single_process_cycle(cycle);
    } else {
        ngx_master_process_cycle(cycle);
    }
    return 0;
}
['int ngx_cdecl\nmain(int argc, char *const *argv)\n{\n    ngx_int_t         i;\n    ngx_log_t        *log;\n    ngx_cycle_t      *cycle, init_cycle;\n    ngx_core_conf_t  *ccf;\n    if (ngx_get_options(argc, argv) != NGX_OK) {\n        return 1;\n    }\n    if (ngx_show_version) {\n        ngx_log_stderr(0, "nginx version: " NGINX_VER);\n        if (ngx_show_help) {\n            ngx_log_stderr(0,\n                "Usage: nginx [-?hvVt] [-s signal] [-c filename] "\n                             "[-p prefix] [-g directives]" CRLF CRLF\n                "Options:" CRLF\n                "  -?,-h         : this help" CRLF\n                "  -v            : show version and exit" CRLF\n                "  -V            : show version and configure options then exit"\n                                   CRLF\n                "  -t            : test configuration and exit" CRLF\n                "  -s signal     : send signal to a master process: "\n                                   "stop, quit, reopen, reload" CRLF\n#ifdef NGX_PREFIX\n                "  -p prefix     : set prefix path (default: "\n                                   NGX_PREFIX ")" CRLF\n#else\n                "  -p prefix     : set prefix path (default: NONE)" CRLF\n#endif\n                "  -c filename   : set configuration file (default: "\n                                   NGX_CONF_PATH ")" CRLF\n                "  -g directives : set global directives out of configuration "\n                                   "file" CRLF\n                );\n        }\n        if (ngx_show_configure) {\n#ifdef NGX_COMPILER\n            ngx_log_stderr(0, "built by " NGX_COMPILER);\n#endif\n            ngx_log_stderr(0, "configure arguments:" NGX_CONFIGURE);\n        }\n        if (!ngx_test_config) {\n            return 0;\n        }\n    }\n#if (NGX_FREEBSD)\n    ngx_debug_init();\n#endif\n      ngx_max_sockets = -1;\n    ngx_time_init();\n#if (NGX_PCRE)\n    ngx_regex_init();\n#endif\n    ngx_pid = ngx_getpid();\n    log = ngx_log_init(ngx_prefix);\n    if (log == NULL) {\n        return 1;\n    }\n#if (NGX_OPENSSL)\n    ngx_ssl_init(log);\n#endif\n    ngx_memzero(&init_cycle, sizeof(ngx_cycle_t));\n    init_cycle.log = log;\n    ngx_cycle = &init_cycle;\n    init_cycle.pool = ngx_create_pool(1024, log);\n    if (init_cycle.pool == NULL) {\n        return 1;\n    }\n    if (ngx_save_argv(&init_cycle, argc, argv) != NGX_OK) {\n        return 1;\n    }\n    if (ngx_process_options(&init_cycle) != NGX_OK) {\n        return 1;\n    }\n    if (ngx_os_init(log) != NGX_OK) {\n        return 1;\n    }\n    if (ngx_crc32_table_init() != NGX_OK) {\n        return 1;\n    }\n    if (ngx_add_inherited_sockets(&init_cycle) != NGX_OK) {\n        return 1;\n    }\n    ngx_max_module = 0;\n    for (i = 0; ngx_modules[i]; i++) {\n        ngx_modules[i]->index = ngx_max_module++;\n    }\n    cycle = ngx_init_cycle(&init_cycle);\n    if (cycle == NULL) {\n        if (ngx_test_config) {\n            ngx_log_stderr(0, "configuration file %s test failed",\n                           init_cycle.conf_file.data);\n        }\n        return 1;\n    }\n    if (ngx_test_config) {\n        ngx_log_stderr(0, "configuration file %s test is successful",\n                       cycle->conf_file.data);\n        return 0;\n    }\n    if (ngx_signal) {\n        return ngx_signal_process(cycle, ngx_signal);\n    }\n    ngx_os_status(cycle->log);\n    ngx_cycle = cycle;\n    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);\n    if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) {\n        ngx_process = NGX_PROCESS_MASTER;\n    }\n#if !(NGX_WIN32)\n    if (ngx_init_signals(cycle->log) != NGX_OK) {\n        return 1;\n    }\n    if (!ngx_inherited && ccf->daemon) {\n        if (ngx_daemon(cycle->log) != NGX_OK) {\n            return 1;\n        }\n        ngx_daemonized = 1;\n    }\n#endif\n    if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {\n        return 1;\n    }\n    if (cycle->log->file->fd != ngx_stderr) {\n        if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,\n                          ngx_set_stderr_n " failed");\n            return 1;\n        }\n    }\n    ngx_use_stderr = 0;\n    if (ngx_process == NGX_PROCESS_SINGLE) {\n        ngx_single_process_cycle(cycle);\n    } else {\n        ngx_master_process_cycle(cycle);\n    }\n    return 0;\n}', 'ngx_cycle_t *\nngx_init_cycle(ngx_cycle_t *old_cycle)\n{\n    void                *rv;\n    char               **senv, **env;\n    ngx_uint_t           i, n;\n    ngx_log_t           *log;\n    ngx_time_t          *tp;\n    ngx_conf_t           conf;\n    ngx_pool_t          *pool;\n    ngx_cycle_t         *cycle, **old;\n    ngx_shm_zone_t      *shm_zone, *oshm_zone;\n    ngx_list_part_t     *part, *opart;\n    ngx_open_file_t     *file;\n    ngx_listening_t     *ls, *nls;\n    ngx_core_conf_t     *ccf, *old_ccf;\n    ngx_core_module_t   *module;\n    char                 hostname[NGX_MAXHOSTNAMELEN];\n    ngx_timezone_update();\n    tp = ngx_timeofday();\n    tp->sec = 0;\n    ngx_time_update(0, 0);\n    log = old_cycle->log;\n    pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);\n    if (pool == NULL) {\n        return NULL;\n    }\n    pool->log = log;\n    cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t));\n    if (cycle == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    cycle->pool = pool;\n    cycle->log = log;\n    cycle->new_log.log_level = NGX_LOG_ERR;\n    cycle->old_cycle = old_cycle;\n    cycle->conf_prefix.len = old_cycle->conf_prefix.len;\n    cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix);\n    if (cycle->conf_prefix.data == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    cycle->prefix.len = old_cycle->prefix.len;\n    cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix);\n    if (cycle->prefix.data == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    cycle->conf_file.len = old_cycle->conf_file.len;\n    cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1);\n    if (cycle->conf_file.data == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data,\n                old_cycle->conf_file.len + 1);\n    cycle->conf_param.len = old_cycle->conf_param.len;\n    cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param);\n    if (cycle->conf_param.data == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;\n    cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));\n    if (cycle->pathes.elts == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    cycle->pathes.nelts = 0;\n    cycle->pathes.size = sizeof(ngx_path_t *);\n    cycle->pathes.nalloc = n;\n    cycle->pathes.pool = pool;\n    if (old_cycle->open_files.part.nelts) {\n        n = old_cycle->open_files.part.nelts;\n        for (part = old_cycle->open_files.part.next; part; part = part->next) {\n            n += part->nelts;\n        }\n    } else {\n        n = 20;\n    }\n    if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))\n        != NGX_OK)\n    {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    if (old_cycle->shared_memory.part.nelts) {\n        n = old_cycle->shared_memory.part.nelts;\n        for (part = old_cycle->shared_memory.part.next; part; part = part->next)\n        {\n            n += part->nelts;\n        }\n    } else {\n        n = 1;\n    }\n    if (ngx_list_init(&cycle->shared_memory, pool, n, sizeof(ngx_shm_zone_t))\n        != NGX_OK)\n    {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;\n    cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));\n    if (cycle->listening.elts == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    cycle->listening.nelts = 0;\n    cycle->listening.size = sizeof(ngx_listening_t);\n    cycle->listening.nalloc = n;\n    cycle->listening.pool = pool;\n    cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));\n    if (cycle->conf_ctx == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    if (gethostname(hostname, NGX_MAXHOSTNAMELEN) == -1) {\n        ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "gethostname() failed");\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    hostname[NGX_MAXHOSTNAMELEN - 1] = \'\\0\';\n    cycle->hostname.len = ngx_strlen(hostname);\n    cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len);\n    if (cycle->hostname.data == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    ngx_memcpy(cycle->hostname.data, hostname, cycle->hostname.len);\n    for (i = 0; ngx_modules[i]; i++) {\n        if (ngx_modules[i]->type != NGX_CORE_MODULE) {\n            continue;\n        }\n        module = ngx_modules[i]->ctx;\n        if (module->create_conf) {\n            rv = module->create_conf(cycle);\n            if (rv == NULL) {\n                ngx_destroy_pool(pool);\n                return NULL;\n            }\n            cycle->conf_ctx[ngx_modules[i]->index] = rv;\n        }\n    }\n    senv = environ;\n    ngx_memzero(&conf, sizeof(ngx_conf_t));\n    conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));\n    if (conf.args == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    conf.temp_pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);\n    if (conf.temp_pool == NULL) {\n        ngx_destroy_pool(pool);\n        return NULL;\n    }\n    conf.ctx = cycle->conf_ctx;\n    conf.cycle = cycle;\n    conf.pool = pool;\n    conf.log = log;\n    conf.module_type = NGX_CORE_MODULE;\n    conf.cmd_type = NGX_MAIN_CONF;\n#if 0\n    log->log_level = NGX_LOG_DEBUG_ALL;\n#endif\n    if (ngx_conf_param(&conf) != NGX_CONF_OK) {\n        environ = senv;\n        ngx_destroy_cycle_pools(&conf);\n        return NULL;\n    }\n    if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {\n        environ = senv;\n        ngx_destroy_cycle_pools(&conf);\n        return NULL;\n    }\n    if (ngx_test_config) {\n        ngx_log_stderr(0, "the configuration file %s syntax is ok",\n                       cycle->conf_file.data);\n    }\n    for (i = 0; ngx_modules[i]; i++) {\n        if (ngx_modules[i]->type != NGX_CORE_MODULE) {\n            continue;\n        }\n        module = ngx_modules[i]->ctx;\n        if (module->init_conf) {\n            if (module->init_conf(cycle, cycle->conf_ctx[ngx_modules[i]->index])\n                == NGX_CONF_ERROR)\n            {\n                environ = senv;\n                ngx_destroy_cycle_pools(&conf);\n                return NULL;\n            }\n        }\n    }\n    if (ngx_process == NGX_PROCESS_SIGNALLER) {\n        return cycle;\n    }\n    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);\n    if (ngx_test_config) {\n        if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {\n            goto failed;\n        }\n    } else if (!ngx_is_init_cycle(old_cycle)) {\n        old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,\n                                                   ngx_core_module);\n        if (ccf->pid.len != old_ccf->pid.len\n            || ngx_strcmp(ccf->pid.data, old_ccf->pid.data) != 0)\n        {\n            if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {\n                goto failed;\n            }\n            ngx_delete_pidfile(old_cycle);\n        }\n    }\n    if (ngx_test_lockfile(cycle->lock_file.data, log) != NGX_OK) {\n        goto failed;\n    }\n    if (ngx_create_pathes(cycle, ccf->user) != NGX_OK) {\n        goto failed;\n    }\n    if (cycle->new_log.file == NULL) {\n        cycle->new_log.file = ngx_conf_open_file(cycle, &error_log);\n        if (cycle->new_log.file == NULL) {\n            goto failed;\n        }\n    }\n    part = &cycle->open_files.part;\n    file = part->elts;\n    for (i = 0;   ; i++) {\n        if (i >= part->nelts) {\n            if (part->next == NULL) {\n                break;\n            }\n            part = part->next;\n            file = part->elts;\n            i = 0;\n        }\n        if (file[i].name.len == 0) {\n            continue;\n        }\n        file[i].fd = ngx_open_file(file[i].name.data,\n                                   NGX_FILE_APPEND,\n                                   NGX_FILE_CREATE_OR_OPEN,\n                                   NGX_FILE_DEFAULT_ACCESS);\n        ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,\n                       "log: %p %d \\"%s\\"",\n                       &file[i], file[i].fd, file[i].name.data);\n        if (file[i].fd == NGX_INVALID_FILE) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,\n                          ngx_open_file_n " \\"%s\\" failed",\n                          file[i].name.data);\n            goto failed;\n        }\n#if !(NGX_WIN32)\n        if (fcntl(file[i].fd, F_SETFD, FD_CLOEXEC) == -1) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,\n                          "fcntl(FD_CLOEXEC) \\"%s\\" failed",\n                          file[i].name.data);\n            goto failed;\n        }\n#endif\n    }\n    cycle->log = &cycle->new_log;\n    pool->log = &cycle->new_log;\n    part = &cycle->shared_memory.part;\n    shm_zone = part->elts;\n    for (i = 0;   ; i++) {\n        if (i >= part->nelts) {\n            if (part->next == NULL) {\n                break;\n            }\n            part = part->next;\n            shm_zone = part->elts;\n            i = 0;\n        }\n        if (shm_zone[i].shm.size == 0) {\n            ngx_log_error(NGX_LOG_EMERG, log, 0,\n                          "zero size shared memory zone \\"%V\\"",\n                          &shm_zone[i].shm.name);\n            goto failed;\n        }\n        if (shm_zone[i].init == NULL) {\n            continue;\n        }\n        shm_zone[i].shm.log = cycle->log;\n        opart = &old_cycle->shared_memory.part;\n        oshm_zone = opart->elts;\n        for (n = 0;   ; n++) {\n            if (n >= opart->nelts) {\n                if (opart->next == NULL) {\n                    break;\n                }\n                opart = opart->next;\n                oshm_zone = opart->elts;\n                n = 0;\n            }\n            if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {\n                continue;\n            }\n            if (ngx_strncmp(shm_zone[i].shm.name.data,\n                            oshm_zone[n].shm.name.data,\n                            shm_zone[i].shm.name.len)\n                != 0)\n            {\n                continue;\n            }\n            if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {\n                shm_zone[i].shm.addr = oshm_zone[n].shm.addr;\n                if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)\n                    != NGX_OK)\n                {\n                    goto failed;\n                }\n                goto shm_zone_found;\n            }\n            ngx_shm_free(&oshm_zone[n].shm);\n            break;\n        }\n        if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) {\n            goto failed;\n        }\n        if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {\n            goto failed;\n        }\n        if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {\n            goto failed;\n        }\n    shm_zone_found:\n        continue;\n    }\n    if (old_cycle->listening.nelts) {\n        ls = old_cycle->listening.elts;\n        for (i = 0; i < old_cycle->listening.nelts; i++) {\n            ls[i].remain = 0;\n        }\n        nls = cycle->listening.elts;\n        for (n = 0; n < cycle->listening.nelts; n++) {\n            for (i = 0; i < old_cycle->listening.nelts; i++) {\n                if (ls[i].ignore) {\n                    continue;\n                }\n                if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) == NGX_OK)\n                {\n                    nls[n].fd = ls[i].fd;\n                    nls[n].previous = &ls[i];\n                    ls[i].remain = 1;\n                    if (ls[n].backlog != nls[i].backlog) {\n                        nls[n].listen = 1;\n                    }\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)\n                    nls[n].deferred_accept = ls[i].deferred_accept;\n                    if (ls[i].accept_filter && nls[n].accept_filter) {\n                        if (ngx_strcmp(ls[i].accept_filter,\n                                       nls[n].accept_filter)\n                            != 0)\n                        {\n                            nls[n].delete_deferred = 1;\n                            nls[n].add_deferred = 1;\n                        }\n                    } else if (ls[i].accept_filter) {\n                        nls[n].delete_deferred = 1;\n                    } else if (nls[n].accept_filter) {\n                        nls[n].add_deferred = 1;\n                    }\n#endif\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)\n                    if (ls[n].deferred_accept && !nls[n].deferred_accept) {\n                        nls[n].delete_deferred = 1;\n                    } else if (ls[i].deferred_accept != nls[n].deferred_accept)\n                    {\n                        nls[n].add_deferred = 1;\n                    }\n#endif\n                    break;\n                }\n            }\n            if (nls[n].fd == -1) {\n                nls[n].open = 1;\n            }\n        }\n    } else {\n        ls = cycle->listening.elts;\n        for (i = 0; i < cycle->listening.nelts; i++) {\n            ls[i].open = 1;\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)\n            if (ls[i].accept_filter) {\n                ls[i].add_deferred = 1;\n            }\n#endif\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)\n            if (ls[i].deferred_accept) {\n                ls[i].add_deferred = 1;\n            }\n#endif\n        }\n    }\n    if (ngx_open_listening_sockets(cycle) != NGX_OK) {\n        goto failed;\n    }\n    if (!ngx_test_config) {\n        ngx_configure_listening_sockets(cycle);\n    }\n    if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {\n        if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,\n                          ngx_set_stderr_n " failed");\n        }\n    }\n    pool->log = cycle->log;\n    for (i = 0; ngx_modules[i]; i++) {\n        if (ngx_modules[i]->init_module) {\n            if (ngx_modules[i]->init_module(cycle) != NGX_OK) {\n                exit(1);\n            }\n        }\n    }\n    opart = &old_cycle->shared_memory.part;\n    oshm_zone = opart->elts;\n    for (i = 0;   ; i++) {\n        if (i >= opart->nelts) {\n            if (opart->next == NULL) {\n                goto old_shm_zone_done;\n            }\n            opart = opart->next;\n            oshm_zone = opart->elts;\n            i = 0;\n        }\n        part = &cycle->shared_memory.part;\n        shm_zone = part->elts;\n        for (n = 0;   ; n++) {\n            if (n >= part->nelts) {\n                if (part->next == NULL) {\n                    break;\n                }\n                part = part->next;\n                shm_zone = part->elts;\n                n = 0;\n            }\n            if (oshm_zone[i].shm.name.len == shm_zone[n].shm.name.len\n                && ngx_strncmp(oshm_zone[i].shm.name.data,\n                               shm_zone[n].shm.name.data,\n                               oshm_zone[i].shm.name.len)\n                == 0)\n            {\n                goto live_shm_zone;\n            }\n        }\n        ngx_shm_free(&oshm_zone[i].shm);\n    live_shm_zone:\n        continue;\n    }\nold_shm_zone_done:\n    ls = old_cycle->listening.elts;\n    for (i = 0; i < old_cycle->listening.nelts; i++) {\n        if (ls[i].remain || ls[i].fd == -1) {\n            continue;\n        }\n        if (ngx_close_socket(ls[i].fd) == -1) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,\n                          ngx_close_socket_n " listening socket on %V failed",\n                          &ls[i].addr_text);\n        }\n    }\n    part = &old_cycle->open_files.part;\n    file = part->elts;\n    for (i = 0;   ; i++) {\n        if (i >= part->nelts) {\n            if (part->next == NULL) {\n                break;\n            }\n            part = part->next;\n            file = part->elts;\n            i = 0;\n        }\n        if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {\n            continue;\n        }\n        if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,\n                          ngx_close_file_n " \\"%s\\" failed",\n                          file[i].name.data);\n        }\n    }\n    ngx_destroy_pool(conf.temp_pool);\n    if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) {\n        env = environ;\n        environ = senv;\n        ngx_destroy_pool(old_cycle->pool);\n        cycle->old_cycle = NULL;\n        environ = env;\n        return cycle;\n    }\n    if (ngx_temp_pool == NULL) {\n        ngx_temp_pool = ngx_create_pool(128, cycle->log);\n        if (ngx_temp_pool == NULL) {\n            ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,\n                          "can not create ngx_temp_pool");\n            exit(1);\n        }\n        n = 10;\n        ngx_old_cycles.elts = ngx_pcalloc(ngx_temp_pool,\n                                          n * sizeof(ngx_cycle_t *));\n        if (ngx_old_cycles.elts == NULL) {\n            exit(1);\n        }\n        ngx_old_cycles.nelts = 0;\n        ngx_old_cycles.size = sizeof(ngx_cycle_t *);\n        ngx_old_cycles.nalloc = n;\n        ngx_old_cycles.pool = ngx_temp_pool;\n        ngx_cleaner_event.handler = ngx_clean_old_cycles;\n        ngx_cleaner_event.log = cycle->log;\n        ngx_cleaner_event.data = &dumb;\n        dumb.fd = (ngx_socket_t) -1;\n    }\n    ngx_temp_pool->log = cycle->log;\n    old = ngx_array_push(&ngx_old_cycles);\n    if (old == NULL) {\n        exit(1);\n    }\n    *old = old_cycle;\n    if (!ngx_cleaner_event.timer_set) {\n        ngx_add_timer(&ngx_cleaner_event, 30000);\n        ngx_cleaner_event.timer_set = 1;\n    }\n    return cycle;\nfailed:\n    if (!ngx_is_init_cycle(old_cycle)) {\n        old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,\n                                                   ngx_core_module);\n        if (old_ccf->environment) {\n            environ = old_ccf->environment;\n        }\n    }\n    part = &cycle->open_files.part;\n    file = part->elts;\n    for (i = 0;   ; i++) {\n        if (i >= part->nelts) {\n            if (part->next == NULL) {\n                break;\n            }\n            part = part->next;\n            file = part->elts;\n            i = 0;\n        }\n        if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {\n            continue;\n        }\n        if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,\n                          ngx_close_file_n " \\"%s\\" failed",\n                          file[i].name.data);\n        }\n    }\n    if (ngx_test_config) {\n        ngx_destroy_cycle_pools(&conf);\n        return NULL;\n    }\n    ls = cycle->listening.elts;\n    for (i = 0; i < cycle->listening.nelts; i++) {\n        if (ls[i].fd == -1 || !ls[i].open) {\n            continue;\n        }\n        if (ngx_close_socket(ls[i].fd) == -1) {\n            ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,\n                          ngx_close_socket_n " %V failed",\n                          &ls[i].addr_text);\n        }\n    }\n    ngx_destroy_cycle_pools(&conf);\n    return NULL;\n}', 'void *\nngx_pcalloc(ngx_pool_t *pool, size_t size)\n{\n    void *p;\n    p = ngx_palloc(pool, size);\n    if (p) {\n        ngx_memzero(p, size);\n    }\n    return p;\n}', 'void *\nngx_palloc(ngx_pool_t *pool, size_t size)\n{\n    u_char      *m;\n    ngx_pool_t  *p;\n    if (size <= pool->max) {\n        p = pool->current;\n        do {\n            m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);\n            if ((size_t) (p->d.end - m) >= size) {\n                p->d.last = m + size;\n                return m;\n            }\n            p = p->d.next;\n        } while (p);\n        return ngx_palloc_block(pool, size);\n    }\n    return ngx_palloc_large(pool, size);\n}']