From 36ecef4f9eda80fc9ae91e6a0a6e74a090a0b680 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Wed, 2 Jan 2008 15:54:58 +0100 Subject: [PATCH] Bugfix in cycle detector. --- lib/url.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/url.c b/lib/url.c index 3a3d8c21..ecc18b00 100644 --- a/lib/url.c +++ b/lib/url.c @@ -707,7 +707,7 @@ int url_has_repeated_component(const byte *url) { struct component *comp, **hash; - uns comps, comp_len, rep_prefix; + uns comps, comp_len, rep_prefix, hash_size; const byte *c; uns i, j; @@ -737,13 +737,15 @@ url_has_repeated_component(const byte *url) comp[i].hash = hashf(comp[i].start, comp[i].length); if (comps > url_max_occurences) { - hash = alloca(comps * sizeof(*hash)); - bzero(hash, comps * sizeof(*hash)); + hash_size = next_table_prime(comps * 2); + hash = alloca(hash_size * sizeof(*hash)); + bzero(hash, hash_size * sizeof(*hash)); for (i=0; istart, comp[i].start, comp[i].length)) - j = (j + 1) % comps; + if (++j == hash_size) + j = 0; if (!hash[j]) { hash[j] = &comp[i]; -- 2.39.2