diff options
author | Adam Jackson <ajax@nwnk.net> | 2006-03-15 01:02:54 +0000 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2006-03-15 01:02:54 +0000 |
commit | 14d1219442c679c754fcc4e27460610ae219951a (patch) | |
tree | 714e8de4eedbe9be270ea89224cdf10ddda39036 | |
parent | ea40d3dd41cb3c562caf404fead9fdaa0b97565c (diff) |
Avoid walking off the end of the hash table. (Coverity report #465)
-rw-r--r-- | libdrm/ChangeLog | 5 | ||||
-rw-r--r-- | libdrm/xf86drmHash.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libdrm/ChangeLog b/libdrm/ChangeLog index b1faa5ef..1e740706 100644 --- a/libdrm/ChangeLog +++ b/libdrm/ChangeLog @@ -1,3 +1,8 @@ +2006-03-14 Adam Jackson <ajax@freedesktop.org> + + * xf86drmHash.c: + Avoid walking off the end of the hash table. (Coverity report #465) + 2006-02-20 Adam Jackson <ajax@freedesktop.org> * ChangeLog: diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c index 71d3d895..a1908d09 100644 --- a/libdrm/xf86drmHash.c +++ b/libdrm/xf86drmHash.c @@ -292,14 +292,15 @@ int drmHashNext(void *t, unsigned long *key, void **value) { HashTablePtr table = (HashTablePtr)t; - for (; table->p0 < HASH_SIZE; - ++table->p0, table->p1 = table->buckets[table->p0]) { + while (table->p0 < HASH_SIZE) { if (table->p1) { *key = table->p1->key; *value = table->p1->value; table->p1 = table->p1->next; return 1; } + table->p1 = table->buckets[table->p0]; + ++table->p0; } return 0; } |