[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28999] trunk/blender/source/blender/ windowmanager/intern/wm_files.c: bugfix [#22426] New Thumbnail code crashes when saving

Campbell Barton ideasman42 at gmail.com
Wed May 26 12:52:39 CEST 2010


Revision: 28999
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28999
Author:   campbellbarton
Date:     2010-05-26 12:52:39 +0200 (Wed, 26 May 2010)

Log Message:
-----------
bugfix [#22426] New Thumbnail code crashes when saving
patch from Ken Nign (ken9). (modified slightly)

Modified Paths:
--------------
    trunk/blender/source/blender/windowmanager/intern/wm_files.c

Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-05-26 10:50:01 UTC (rev 28998)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-05-26 10:52:39 UTC (rev 28999)
@@ -502,9 +502,7 @@
 	
 	if(G.background || scene->camera==NULL)
 		return;
-	
-	thumb = MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb");
-	
+
 	/* gets scaled to BLEN_THUMB_SIZE */
 	ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, OB_SOLID);
 	
@@ -514,17 +512,25 @@
 		IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE);
 		
 		/* first write into thumb buffer */
+		thumb= MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb");
+
 		thumb[0] = BLEN_THUMB_SIZE;
 		thumb[1] = BLEN_THUMB_SIZE;
+
 		memcpy(thumb + 2, ibuf->rect, BLEN_THUMB_SIZE * BLEN_THUMB_SIZE * sizeof(int));
 		
 		/* the image is scaled here */
 		ibuf= IMB_thumb_create(path, THB_NORMAL, THB_SOURCE_BLEND, ibuf);
-	}
 
-	if (ibuf) {		
-		IMB_freeImBuf(ibuf);
+		if (ibuf)
+			IMB_freeImBuf(ibuf);
+
+		ibuf= NULL;
 	}
+	else {
+		/* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */
+		thumb= NULL;
+	}
 	
 	/* must be freed by caller */
 	*thumb_pt= thumb;





More information about the Bf-blender-cvs mailing list