[Bf-blender-cvs] [236be8e9f1c] master: Fix T93380: Texture paint clone tool crash without clone image

Philipp Oeser noreply at git.blender.org
Fri Nov 26 11:51:09 CET 2021


Commit: 236be8e9f1c92fe47fee9af72dad752f3a5452ee
Author: Philipp Oeser
Date:   Fri Nov 26 08:33:45 2021 +0100
Branches: master
https://developer.blender.org/rB236be8e9f1c92fe47fee9af72dad752f3a5452ee

Fix T93380: Texture paint clone tool crash without clone image

This was crashing using the clone tool without a clone image assigned.

Caused by {rB9111ea78acf4}.
Since above commit, `BKE_image_acquire_ibuf` was using `ima->runtime`
without checking for NULL first.
Since callers are not required to check for this, just return early
here.

note: there is still a memory leak using the clone tool without a clone
image assigned (but this was also the case before said commit and needs
to be investigated separately).

Maniphest Tasks: T93380

Differential Revision: https://developer.blender.org/D13377

===================================================================

M	source/blender/blenkernel/intern/image.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 99700634288..22529467a14 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -5142,12 +5142,16 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
 /* return image buffer for given image and user
  *
  * - will lock render result if image type is render result and lock is not NULL
- * - will return NULL if image type if render or composite result and lock is NULL
+ * - will return NULL if image is NULL or image type is render or composite result and lock is NULL
  *
  * references the result, BKE_image_release_ibuf should be used to de-reference
  */
 ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
 {
+  if (ima == NULL) {
+    return NULL;
+  }
+
   ImBuf *ibuf;
 
   BLI_mutex_lock(ima->runtime.cache_mutex);



More information about the Bf-blender-cvs mailing list