random seed used in the hash of all strings to avoid intentional

collisions
This commit is contained in:
Roberto Ierusalimschy
2012-02-01 19:57:15 -02:00
parent a4b96ce9a3
commit 678c1255c9
5 changed files with 49 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltable.c,v 2.67 2011/11/30 12:41:45 roberto Exp roberto $
** $Id: ltable.c,v 2.69 2012/01/25 21:05:40 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -101,7 +101,7 @@ static Node *mainposition (const Table *t, const TValue *key) {
case LUA_TLNGSTR: {
TString *s = rawtsvalue(key);
if (s->tsv.extra == 0) { /* no hash? */
s->tsv.hash = luaS_hash(getstr(s), s->tsv.len);
s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash);
s->tsv.extra = 1; /* now it has its hash */
}
return hashstr(t, rawtsvalue(key));