Tomato: fixed crash caused by interaction between color management and
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 3 Jul 2012 16:00:57 +0000 (16:00 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 3 Jul 2012 16:00:57 +0000 (16:00 +0000)
movie clip caches resulting in some unchecked NULL pointers.

Probably it'll be better to separate memory limitors for cache and
clips or double-check priority functions are fine to deal with
such cases.

intern/memutil/MEM_CacheLimiter.h
source/blender/imbuf/intern/moviecache.c

index e90e002b28cf8a25bb3cf06b632a2b4987eb7cf7..bc92f9b5af85ef57a8425074d723d408949cfe8f 100644 (file)
@@ -254,7 +254,8 @@ private:
                        MEM_CacheElementPtr elem = *it;
                        int priority;
 
-                       priority = i;
+                       /* by default 0 means higherst priority element */
+                       priority = queue.size() - i - 1;
 
                        if (getItemPriority) {
                                priority = getItemPriority(elem->get()->get_data(), priority);
index 04d563dd0ea5cb21a4c62b074ea761603537572e..f3442eb4147375779dbbf2a890d295fbc1d9fd0a 100644 (file)
@@ -219,6 +219,14 @@ static int get_item_priority(void *item_v, int default_priority)
        if (!cache->getitempriorityfp)
                return default_priority;
 
+       if (!cache->last_userkey) {
+               /* happens when cache was overflow when adding element to one cache
+                * and elements from other cache are being measured as well
+                */
+
+               return default_priority;
+       }
+
        return cache->getitempriorityfp(cache->last_userkey, item->priority_data);
 }