1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Fix hash lookup segfault when keys compared are different lengths.

This commit is contained in:
Alasdair Kergon 2009-11-03 00:45:35 +00:00
parent 1ace1b5ddf
commit eb82f939ee

View File

@ -143,9 +143,13 @@ static struct dm_hash_node **_find(struct dm_hash_table *t, const char *key,
unsigned h = _hash(key, len) & (t->num_slots - 1); unsigned h = _hash(key, len) & (t->num_slots - 1);
struct dm_hash_node **c; struct dm_hash_node **c;
for (c = &t->slots[h]; *c; c = &((*c)->next)) for (c = &t->slots[h]; *c; c = &((*c)->next)) {
if ((*c)->keylen != len)
continue;
if (!memcmp(key, (*c)->key, len)) if (!memcmp(key, (*c)->key, len))
break; break;
}
return c; return c;
} }