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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-01-21 15:38:15 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-01-21 15:38:15 +0400
commit838064679894f41034c1f6e78ae33a81b4f14c75 (patch)
tree92f33c61e39f1b5e857394d772efb24257bb71c6 /source
parent2e18f7ff93e6c403b4fb81ecc98770fff9138be3 (diff)
Fix image pool crash when acquiring buffer for NULL image
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/image.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 90158f8cc70..c56091ead62 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2888,6 +2888,21 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame
return ibuf;
}
+BLI_INLINE int image_quick_test(Image *ima, ImageUser *iuser)
+{
+ if (ima == NULL)
+ return FALSE;
+
+ if (iuser) {
+ if (iuser->ok == 0)
+ return FALSE;
+ }
+ else if (ima->ok == 0)
+ return FALSE;
+
+ return TRUE;
+}
+
/* Checks optional ImageUser and verifies/creates ImBuf.
*
* not thread-safe, so callee should worry about thread locks
@@ -2902,14 +2917,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
*lock_r = NULL;
/* quick reject tests */
- if (ima == NULL)
- return NULL;
-
- if (iuser) {
- if (iuser->ok == 0)
- return NULL;
- }
- else if (ima->ok == 0)
+ if (!image_quick_test(ima, iuser))
return NULL;
ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index);
@@ -3033,14 +3041,7 @@ int BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
ImBuf *ibuf;
/* quick reject tests */
- if (ima == NULL)
- return FALSE;
-
- if (iuser) {
- if (iuser->ok == 0)
- return FALSE;
- }
- else if (ima->ok == 0)
+ if (!image_quick_test(ima, iuser))
return FALSE;
ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL);
@@ -3122,6 +3123,9 @@ ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool
ImBuf *ibuf;
int index, frame, found;
+ if (!image_quick_test(ima, iuser))
+ return NULL;
+
if (pool == NULL) {
/* pool could be NULL, in this case use general acquire function */
return BKE_image_acquire_ibuf(ima, iuser, NULL);