aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Jackson2006-03-14 19:02:54 -0600
committerAdam Jackson2006-03-14 19:02:54 -0600
commit14d1219442c679c754fcc4e27460610ae219951a (patch)
tree714e8de4eedbe9be270ea89224cdf10ddda39036 /libdrm/xf86drmHash.c
parentea40d3dd41cb3c562caf404fead9fdaa0b97565c (diff)
downloadlibdrm-14d1219442c679c754fcc4e27460610ae219951a.tar.gz
libdrm-14d1219442c679c754fcc4e27460610ae219951a.tar.xz
libdrm-14d1219442c679c754fcc4e27460610ae219951a.zip
Avoid walking off the end of the hash table. (Coverity report #465)
Diffstat (limited to 'libdrm/xf86drmHash.c')
-rw-r--r--libdrm/xf86drmHash.c5
1 files changed, 3 insertions, 2 deletions
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)
292{ 292{
293 HashTablePtr table = (HashTablePtr)t; 293 HashTablePtr table = (HashTablePtr)t;
294 294
295 for (; table->p0 < HASH_SIZE; 295 while (table->p0 < HASH_SIZE) {
296 ++table->p0, table->p1 = table->buckets[table->p0]) {
297 if (table->p1) { 296 if (table->p1) {
298 *key = table->p1->key; 297 *key = table->p1->key;
299 *value = table->p1->value; 298 *value = table->p1->value;
300 table->p1 = table->p1->next; 299 table->p1 = table->p1->next;
301 return 1; 300 return 1;
302 } 301 }
302 table->p1 = table->buckets[table->p0];
303 ++table->p0;
303 } 304 }
304 return 0; 305 return 0;
305} 306}