[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41213] trunk/blender/source/blender: BLI_make_file_string wasn't guaranteed to initialize the resulting path, some parts of the code accounted for this but most not, always initialize the string to "".

Campbell Barton ideasman42 at gmail.com
Sun Oct 23 07:56:56 CEST 2011


Revision: 41213
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41213
Author:   campbellbarton
Date:     2011-10-23 05:56:55 +0000 (Sun, 23 Oct 2011)
Log Message:
-----------
BLI_make_file_string wasn't guaranteed to initialize the resulting path, some parts of the code accounted for this but most not, always initialize the string to "".

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/editors/render/render_preview.c

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2011-10-23 05:08:02 UTC (rev 41212)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2011-10-23 05:56:55 UTC (rev 41213)
@@ -1257,10 +1257,19 @@
 {
 	int sl;
 
-	if (!string || !dir || !file) return; /* We don't want any NULLs */
-	
-	string[0]= 0; /* ton */
+	if (string) {
+		/* ensure this is always set even if dir/file are NULL */
+		string[0]= '\0';
 
+		if (ELEM(NULL, dir, file)) {
+			return; /* We don't want any NULLs */
+		}
+	}
+	else {
+		return; /* string is NULL, probably shouldnt happen but return anyway */
+	}
+
+
 	/* we first push all slashes into unix mode, just to make sure we don't get
 	   any mess with slashes later on. -jesterKing */
 	/* constant strings can be passed for those parameters - don't change them - elubie */

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2011-10-23 05:08:02 UTC (rev 41212)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2011-10-23 05:56:55 UTC (rev 41213)
@@ -2699,7 +2699,6 @@
 		}
 	}
 
-	userfilename[0]= '\0'; /* ensure its initialized */
 	BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
 	write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
 

Modified: trunk/blender/source/blender/editors/render/render_preview.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_preview.c	2011-10-23 05:08:02 UTC (rev 41212)
+++ trunk/blender/source/blender/editors/render/render_preview.c	2011-10-23 05:56:55 UTC (rev 41213)
@@ -122,8 +122,6 @@
 				if (!(brush->icon_imbuf)) {
 					folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons");
 
-					path[0]= 0;
-
 					BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
 
 					if (path[0])




More information about the Bf-blender-cvs mailing list