bugfix: added allocation failure check for ngx_array_init(). thanks Tatsuhiko Kubo for the patch in #414.

This commit is contained in:
Yichun Zhang (agentzh) 2014-08-21 12:47:16 -07:00
Родитель 0e49fe7462
Коммит eb128df045
2 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -51,7 +51,12 @@ ngx_http_lua_shared_dict(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
ngx_array_init(lmcf->shm_zones, cf->pool, 2, sizeof(ngx_shm_zone_t *));
if (ngx_array_init(lmcf->shm_zones, cf->pool, 2,
sizeof(ngx_shm_zone_t *))
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
}
value = cf->args->elts;

Просмотреть файл

@ -82,14 +82,22 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
#endif
ngx_array_init(&fake_cycle->listening, cycle->pool,
cycle->listening.nelts || 1,
sizeof(ngx_listening_t));
if (ngx_array_init(&fake_cycle->listening, cycle->pool,
cycle->listening.nelts || 1,
sizeof(ngx_listening_t))
!= NGX_OK)
{
goto failed;
}
#if defined(nginx_version) && nginx_version >= 1003007
ngx_array_init(&fake_cycle->paths, cycle->pool, cycle->paths.nelts || 1,
sizeof(ngx_path_t *));
if (ngx_array_init(&fake_cycle->paths, cycle->pool, cycle->paths.nelts || 1,
sizeof(ngx_path_t *))
!= NGX_OK)
{
goto failed;
}
#endif