From 236be8e9f1c92fe47fee9af72dad752f3a5452ee Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 26 Nov 2021 08:33:45 +0100 Subject: [PATCH] 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 --- source/blender/blenkernel/intern/image.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);