Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-05 22:26:17 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-05 22:29:36 +0300
commit5ae853d20a3a5e41660220e684be1c7b785256d2 (patch)
tree1dda80a67d9371cfc63312cae595d74fb8ec70a8
parent46060d54bffe48fe4cb46fe101ae79246b2b5513 (diff)
Fix (unreported) potential race condition in view_layer_bases_hash_create().
When you check for undone work before acquiring a lock that ensures you are the only one actually doing the work, you have to redo the check *after* acquiring said lock. Otherwise, there is room for nasty random race condition issues...
-rw-r--r--source/blender/blenkernel/intern/layer.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 65851bb032d..c259ec0da9c 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -305,14 +305,16 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer)
{
static ThreadMutex hash_lock = BLI_MUTEX_INITIALIZER;
- if (!view_layer->object_bases_hash) {
+ if (view_layer->object_bases_hash == NULL) {
BLI_mutex_lock(&hash_lock);
- view_layer->object_bases_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ if (view_layer->object_bases_hash == NULL) {
+ view_layer->object_bases_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if (base->object) {
- BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+ for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if (base->object) {
+ BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+ }
}
}