diff options
| author | Ian Lance Taylor <iant@golang.org> | 2013-01-04 07:53:42 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2013-01-04 07:53:42 -0800 |
| commit | 63bee953a2d3aea703de1f4980f557d2af645dc9 (patch) | |
| tree | effd8e5e201e594858f3139bb11cbb6c362b88b1 /src/pkg/runtime/alg.c | |
| parent | c09649890fd48f9854120999a109ba968596a021 (diff) | |
| download | go-63bee953a2d3aea703de1f4980f557d2af645dc9.tar.xz | |
runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions.
R=golang-dev, dave, patrick, rsc
CC=golang-dev
https://golang.org/cl/7051043
Diffstat (limited to 'src/pkg/runtime/alg.c')
| -rw-r--r-- | src/pkg/runtime/alg.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/runtime/alg.c b/src/pkg/runtime/alg.c index c7424bc262..ad85b43aef 100644 --- a/src/pkg/runtime/alg.c +++ b/src/pkg/runtime/alg.c @@ -19,13 +19,13 @@ runtime·memhash(uintptr *h, uintptr s, void *a) uintptr hash; b = a; - hash = M0; + hash = M0 ^ *h; while(s > 0) { hash = (hash ^ *b) * M1; b++; s--; } - *h = (*h ^ hash) * M1; + *h = hash; } void @@ -355,7 +355,7 @@ void runtime·interhash(uintptr *h, uintptr s, void *a) { USED(s); - *h = (*h ^ runtime·ifacehash(*(Iface*)a)) * M1; + *h = runtime·ifacehash(*(Iface*)a, *h ^ M0) * M1; } void @@ -389,7 +389,7 @@ void runtime·nilinterhash(uintptr *h, uintptr s, void *a) { USED(s); - *h = (*h ^ runtime·efacehash(*(Eface*)a)) * M1; + *h = runtime·efacehash(*(Eface*)a, *h ^ M0) * M1; } void |
