diff options
author | Valentin Bartenev <vbart@nginx.com> | 2012-01-16 16:42:07 +0400 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2012-01-16 16:42:07 +0400 |
commit | 363a0c53e755750346113d9c5c9cb1a2905d2d2d (patch) | |
tree | 9add4528a42de86050b9d88adb675c89efb3afd3 /src/core/ngx_hash.c | |
parent | b904676b5e687c8aeabcce297aa6250e07e63462 (diff) |
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 {}
}
Diffstat (limited to 'src/core/ngx_hash.c')
-rw-r--r-- | src/core/ngx_hash.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c index 0c7285202..74d89b8b9 100644 --- a/src/core/ngx_hash.c +++ b/src/core/ngx_hash.c @@ -277,7 +277,7 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts) 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; } |