comparison src/core/ngx_hash.c @ 4449:b80b278fe470 stable-1.0

Merge of r4405: 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.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 05 Feb 2012 19:27:18 +0000
parents 4c70bbdfd076
children d620f497c50f
comparison
equal deleted inserted replaced
4448:539355d9e675 4449:b80b278fe470
275 bucket_size = hinit->bucket_size - sizeof(void *); 275 bucket_size = hinit->bucket_size - sizeof(void *);
276 276
277 start = nelts / (bucket_size / (2 * sizeof(void *))); 277 start = nelts / (bucket_size / (2 * sizeof(void *)));
278 start = start ? start : 1; 278 start = start ? start : 1;
279 279
280 if (hinit->max_size > 10000 && hinit->max_size / nelts < 100) { 280 if (hinit->max_size > 10000 && nelts && hinit->max_size / nelts < 100) {
281 start = hinit->max_size - 1000; 281 start = hinit->max_size - 1000;
282 } 282 }
283 283
284 for (size = start; size < hinit->max_size; size++) { 284 for (size = start; size < hinit->max_size; size++) {
285 285