Mesa (master): u_cache: fix dereference before NULL check

Dave Airlie airlied at kemper.freedesktop.org
Tue Dec 4 08:02:55 UTC 2012


Module: Mesa
Branch: master
Commit: a853301fb7428138618cab67542e401afb808fbf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a853301fb7428138618cab67542e401afb808fbf

Author: Dave Airlie <airlied at gmail.com>
Date:   Fri Nov 30 18:48:47 2012 +1000

u_cache: fix dereference before NULL check

---

 src/gallium/auxiliary/util/u_cache.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c
index df08ec3..26aab2b 100644
--- a/src/gallium/auxiliary/util/u_cache.c
+++ b/src/gallium/auxiliary/util/u_cache.c
@@ -183,12 +183,12 @@ util_cache_set(struct util_cache *cache,
                void *value)
 {
    struct util_cache_entry *entry;
-   uint32_t hash = cache->hash(key);
+   uint32_t hash;
 
    assert(cache);
    if (!cache)
       return;
-
+   hash = cache->hash(key);
    entry = util_cache_entry_get(cache, hash, key);
    if (!entry)
       entry = cache->lru.prev;
@@ -218,12 +218,12 @@ util_cache_get(struct util_cache *cache,
                const void *key)
 {
    struct util_cache_entry *entry;
-   uint32_t hash = cache->hash(key);
+   uint32_t hash;
 
    assert(cache);
    if (!cache)
       return NULL;
-
+   hash = cache->hash(key);
    entry = util_cache_entry_get(cache, hash, key);
    if (!entry)
       return NULL;




More information about the mesa-commit mailing list