Mercurial > hg > nginx
comparison src/core/ngx_hash.c @ 6225:3b6d69857de2
Core: fixed potential division by zero when initializing hash.
Found by Clang Static Analyzer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 13 Aug 2015 16:27:17 +0300 |
parents | ddf35e019a80 |
children | 3cf25d33886a |
comparison
equal
deleted
inserted
replaced
6224:ddf35e019a80 | 6225:3b6d69857de2 |
---|---|
255 size_t len; | 255 size_t len; |
256 u_short *test; | 256 u_short *test; |
257 ngx_uint_t i, n, key, size, start, bucket_size; | 257 ngx_uint_t i, n, key, size, start, bucket_size; |
258 ngx_hash_elt_t *elt, **buckets; | 258 ngx_hash_elt_t *elt, **buckets; |
259 | 259 |
260 if (hinit->max_size == 0) { | |
261 ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0, | |
262 "could not build %s, you should " | |
263 "increase %s_max_size: %i", | |
264 hinit->name, hinit->name, hinit->max_size); | |
265 return NGX_ERROR; | |
266 } | |
267 | |
260 for (n = 0; n < nelts; n++) { | 268 for (n = 0; n < nelts; n++) { |
261 if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *)) | 269 if (hinit->bucket_size < NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *)) |
262 { | 270 { |
263 ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0, | 271 ngx_log_error(NGX_LOG_EMERG, hinit->pool->log, 0, |
264 "could not build %s, you should " | 272 "could not build %s, you should " |