]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4405:
authorMaxim Dounin <mdounin@mdounin.ru>
Sun, 5 Feb 2012 19:27:18 +0000 (19:27 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Sun, 5 Feb 2012 19:27:18 +0000 (19:27 +0000)
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.

src/core/ngx_hash.c

index 0c7285202fbd1a3f7b19ecf7dd8867a3e5b27e5a..74d89b8b9480cc39327357e621f361837a51feb2 100644 (file)
@@ -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;
     }