OSDN Git Service

GenerationCache::get would return a random value instead of NULL
authorRomain Guy <romainguy@google.com>
Fri, 9 Dec 2011 02:19:39 +0000 (18:19 -0800)
committerRomain Guy <romainguy@google.com>
Fri, 9 Dec 2011 02:50:27 +0000 (18:50 -0800)
Bug #5401917

This was causing a ton of random crashes in apps.

Change-Id: I9069a060824ec89115cd3bcd38beaeb9ecc4488e

include/utils/GenerationCache.h

index 83cda86..da85a9a 100644 (file)
@@ -88,11 +88,13 @@ private:
 
     void attachToCache(const sp<Entry<K, V> >& entry);
     void detachFromCache(const sp<Entry<K, V> >& entry);
+
+    const V mNullValue;
 }; // class GenerationCache
 
 template<typename K, typename V>
 GenerationCache<K, V>::GenerationCache(uint32_t maxCapacity): mMaxCapacity(maxCapacity),
-    mListener(NULL) {
+    mListener(NULL), mNullValue(NULL) {
 };
 
 template<typename K, typename V>
@@ -154,7 +156,7 @@ const V& GenerationCache<K, V>::get(const K& key) {
         return entry->value;
     }
 
-    return NULL;
+    return mNullValue;
 }
 
 template<typename K, typename V>