# HG changeset patch # User Valentin Bartenev # Date 1326717727 0 # Node ID 840f3e768ef85c65e4f0d94fa149c93e5a4a0fc0 # Parent c8b9f62cb4143ff3b22e8168639a8069512a9258 Fixed division by zero exception in ngx_hash_init(). The ngx_hash_init() function did not expect call with zero elements count, which caused FPE error on configs with an empty "types" block in http context and "types_hash_max_size" > 10000. Example configuration to reproduce: events { } http { types_hash_max_size 10001; types {} server {} } diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c --- a/src/core/ngx_hash.c +++ b/src/core/ngx_hash.c @@ -277,7 +277,7 @@ ngx_hash_init(ngx_hash_init_t *hinit, ng start = nelts / (bucket_size / (2 * sizeof(void *))); start = start ? start : 1; - if (hinit->max_size > 10000 && hinit->max_size / nelts < 100) { + if (hinit->max_size > 10000 && nelts && hinit->max_size / nelts < 100) { start = hinit->max_size - 1000; }