From: Adam Jackson Date: Wed, 15 Mar 2006 01:02:54 +0000 (+0000) Subject: Avoid walking off the end of the hash table. (Coverity report #465) X-Git-Tag: submit/1.0/20121108.012404~1476 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14d1219442c679c754fcc4e27460610ae219951a;p=profile%2Fivi%2Flibdrm.git Avoid walking off the end of the hash table. (Coverity report #465) --- diff --git a/libdrm/ChangeLog b/libdrm/ChangeLog index b1faa5e..1e74070 100644 --- a/libdrm/ChangeLog +++ b/libdrm/ChangeLog @@ -1,3 +1,8 @@ +2006-03-14 Adam Jackson + + * xf86drmHash.c: + Avoid walking off the end of the hash table. (Coverity report #465) + 2006-02-20 Adam Jackson * ChangeLog: diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c index 71d3d89..a1908d0 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; }