summaryrefslogtreecommitdiff
path: root/libguile/hash.c
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2014-01-12 07:11:44 -0500
committerMark H Weaver <mhw@netris.org>2014-01-12 07:38:04 -0500
commit63d869e74c183faf8e73c73908ef912fdb20198e (patch)
tree3a142f5bc1b39cab7f9926a1e2bbff1e47fa3502 /libguile/hash.c
parentf974224d97bce334b6dcf20ecd8ffa84d270e0cd (diff)
downloadguile-63d869e74c183faf8e73c73908ef912fdb20198e.tar.gz
Fix hashing of empty vectors.
Fixes a bug introduced in cc1cd04f8111c306cf48b93e131d5c1765c808a3 "Fix hashing of vectors to run in bounded time." * libguile/hash.c (scm_hasher): Avoid division by zero. * test-suite/tests/hash.test ("hash"): Add tests.
Diffstat (limited to 'libguile/hash.c')
-rw-r--r--libguile/hash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libguile/hash.c b/libguile/hash.c
index c0a6109b4..342931051 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -245,7 +245,7 @@ scm_hasher(SCM obj, unsigned long n, size_t d)
{
i = len;
h = n - 1;
- d2 = (d - 1) / len;
+ d2 = len > 0 ? (d - 1) / len : 0;
}
while (i--)