diff options
author | Zack Rusin <zack@kde.org> | 2009-06-20 21:19:57 -0400 |
---|---|---|
committer | Zack Rusin <zack@kde.org> | 2009-07-06 17:21:37 -0400 |
commit | 4873031e29e0e8f654f78307e6ec885e68a54d86 (patch) | |
tree | ec6469eec2588f82c2049e260dbcb5c42f0a34e1 /src/gallium/auxiliary/util/u_hash_table.c | |
parent | 21cce6afb03bf9b9adfc6d8a1a446bb3ef22c7a8 (diff) |
util: fix possible null pointer usage
found by the clang static analyzer
Diffstat (limited to 'src/gallium/auxiliary/util/u_hash_table.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_hash_table.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index 2f83e318e4..8c2a8f454c 100644 --- a/src/gallium/auxiliary/util/u_hash_table.c +++ b/src/gallium/auxiliary/util/u_hash_table.c @@ -148,6 +148,8 @@ hash_table_set(struct hash_table *ht, struct cso_hash_iter iter; assert(ht); + if (!ht) + return PIPE_ERROR_BAD_INPUT; key_hash = ht->hash(key); @@ -183,6 +185,8 @@ hash_table_get(struct hash_table *ht, struct hash_table_item *item; assert(ht); + if (!ht) + return NULL; key_hash = ht->hash(key); @@ -203,6 +207,8 @@ hash_table_remove(struct hash_table *ht, struct hash_table_item *item; assert(ht); + if (!ht) + return; key_hash = ht->hash(key); @@ -225,7 +231,9 @@ hash_table_clear(struct hash_table *ht) struct hash_table_item *item; assert(ht); - + if (!ht) + return; + iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { item = (struct hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter)); @@ -243,9 +251,11 @@ hash_table_foreach(struct hash_table *ht, struct cso_hash_iter iter; struct hash_table_item *item; enum pipe_error result; - + assert(ht); - + if (!ht) + return PIPE_ERROR_BAD_INPUT; + iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { item = (struct hash_table_item *)cso_hash_iter_data(iter); @@ -264,9 +274,11 @@ hash_table_destroy(struct hash_table *ht) { struct cso_hash_iter iter; struct hash_table_item *item; - + assert(ht); - + if (!ht) + return; + iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { item = (struct hash_table_item *)cso_hash_iter_data(iter); |