summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_cache.c
diff options
context:
space:
mode:
authorZack Rusin <zack@kde.org>2009-06-20 21:19:57 -0400
committerZack Rusin <zack@kde.org>2009-07-06 17:21:37 -0400
commit4873031e29e0e8f654f78307e6ec885e68a54d86 (patch)
treeec6469eec2588f82c2049e260dbcb5c42f0a34e1 /src/gallium/auxiliary/util/u_cache.c
parent21cce6afb03bf9b9adfc6d8a1a446bb3ef22c7a8 (diff)
util: fix possible null pointer usage
found by the clang static analyzer
Diffstat (limited to 'src/gallium/auxiliary/util/u_cache.c')
-rw-r--r--src/gallium/auxiliary/util/u_cache.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c
index 41cd38171f..47c16b1c92 100644
--- a/src/gallium/auxiliary/util/u_cache.c
+++ b/src/gallium/auxiliary/util/u_cache.c
@@ -137,6 +137,8 @@ util_cache_set(struct util_cache *cache,
struct util_cache_entry *entry;
assert(cache);
+ if (!cache)
+ return;
entry = util_cache_entry_get(cache, key);
util_cache_entry_destroy(cache, entry);
@@ -158,6 +160,8 @@ util_cache_get(struct util_cache *cache,
struct util_cache_entry *entry;
assert(cache);
+ if (!cache)
+ return NULL;
entry = util_cache_entry_get(cache, key);
if(!entry->key && !entry->value)
@@ -176,7 +180,9 @@ util_cache_clear(struct util_cache *cache)
uint32_t i;
assert(cache);
-
+ if (!cache)
+ return;
+
for(i = 0; i < cache->size; ++i)
util_cache_entry_destroy(cache, &cache->entries[i]);
}
@@ -186,6 +192,8 @@ void
util_cache_destroy(struct util_cache *cache)
{
assert(cache);
+ if (!cache)
+ return;
#ifdef DEBUG
if(cache->count >= 20*cache->size) {