Fix T92740: Missing lock around the image CacheLimiter
A recent change exposed this long-standing race. Simply protect the MEM_CacheLimiter with its lock now. Additionally, guard against unmanaging an already destroyed cache handle. Ref T92740, T92838
This commit is contained in:
parent
0a6b6eb13b
commit
ff5630b7fa
Notes:
blender-bot
2023-02-14 06:55:40 +01:00
Referenced by issue #93479, 3.0 Potential candidates for corrective releases Referenced by issue #92838, Crash when exceeding memory_cache_limit in the viewport Referenced by issue #92740, BlenLib/ImageCache : Use after free
|
@ -122,7 +122,12 @@ static void moviecache_valfree(void *val)
|
|||
|
||||
PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf);
|
||||
|
||||
MEM_CacheLimiter_unmanage(item->c_handle);
|
||||
BLI_mutex_lock(&limitor_lock);
|
||||
if (item->c_handle) {
|
||||
MEM_CacheLimiter_unmanage(item->c_handle);
|
||||
}
|
||||
BLI_mutex_unlock(&limitor_lock);
|
||||
|
||||
if (item->ibuf) {
|
||||
IMB_freeImBuf(item->ibuf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue