From 6f5d1e257e727d73d62a1ab4efbbd9fa1332a4e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Sep 2015 23:23:44 +1000 Subject: Add missing spin-lock to IMB_makeSingleUser --- source/blender/imbuf/intern/allocimbuf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/imbuf/intern') diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 9042c4bd09c..b8771e372cf 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -206,7 +206,18 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf) { ImBuf *rval; - if (!ibuf || ibuf->refcounter == 0) { return ibuf; } + if (ibuf) { + bool is_single; + BLI_spin_lock(&refcounter_spin); + is_single = (ibuf->refcounter == 0); + BLI_spin_unlock(&refcounter_spin); + if (is_single) { + return ibuf; + } + } + else { + return NULL; + } rval = IMB_dupImBuf(ibuf); -- cgit v1.2.3