[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53954] trunk/blender/source/blender/ blenkernel/intern/image.c: Fix image pool crash when acquiring buffer for NULL image

Sergey Sharybin sergey.vfx at gmail.com
Mon Jan 21 12:38:19 CET 2013


Revision: 53954
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53954
Author:   nazgul
Date:     2013-01-21 11:38:15 +0000 (Mon, 21 Jan 2013)
Log Message:
-----------
Fix image pool crash when acquiring buffer for NULL image

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2013-01-21 11:25:04 UTC (rev 53953)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2013-01-21 11:38:15 UTC (rev 53954)
@@ -2888,6 +2888,21 @@
 	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,16 +2917,9 @@
 		*lock_r = NULL;
 
 	/* quick reject tests */
-	if (ima == NULL)
+	if (!image_quick_test(ima, iuser))
 		return NULL;
 
-	if (iuser) {
-		if (iuser->ok == 0)
-			return NULL;
-	}
-	else if (ima->ok == 0)
-		return NULL;
-
 	ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index);
 
 	if (ibuf == NULL) {
@@ -3033,16 +3041,9 @@
 	ImBuf *ibuf;
 
 	/* quick reject tests */
-	if (ima == NULL)
+	if (!image_quick_test(ima, iuser))
 		return FALSE;
 
-	if (iuser) {
-		if (iuser->ok == 0)
-			return FALSE;
-	}
-	else if (ima->ok == 0)
-		return FALSE;
-
 	ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL);
 
 	if (!ibuf) {
@@ -3122,6 +3123,9 @@
 	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);




More information about the Bf-blender-cvs mailing list