summaryrefslogtreecommitdiff
path: root/crawler.c
diff options
context:
space:
mode:
authorFumihiro Ito <fmhrit@gmail.com>2017-04-03 15:12:43 +0000
committerdormando <dormando@rydia.net>2017-05-22 22:32:07 -0700
commit1afac9c46fb8bfd08ee3e44aad8de544a2151bbe (patch)
tree3edbe9f20f8a5f9908ff8c07c8ccccd07775af21 /crawler.c
parentf0a3c4954fccc178c8e3e1948ff58cb3279d9783 (diff)
downloadmemcached-1afac9c46fb8bfd08ee3e44aad8de544a2151bbe.tar.gz
check index at increments crawlerstats_t->histo
Very rarely, current_time will be greater than expiration time of item. If an item has expired at after check its expiration in crawler thread, access to crawlerstats_t->histo with invalid index. so segmentation fault occurs as a result of access violation.
Diffstat (limited to 'crawler.c')
-rw-r--r--crawler.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crawler.c b/crawler.c
index 43245ea..93f7e1a 100644
--- a/crawler.c
+++ b/crawler.c
@@ -207,7 +207,9 @@ static void crawler_expired_eval(crawler_module_t *cm, item *search, uint32_t hv
} else {
rel_time_t ttl_remain = search->exptime - current_time;
int bucket = ttl_remain / 60;
- s->histo[bucket]++;
+ if (bucket <= 60) {
+ s->histo[bucket]++;
+ }
}
}
pthread_mutex_unlock(&d->lock);