BLI_make_file_string wasn't guaranteed to initialize the resulting path, some parts...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 23 Oct 2011 05:56:55 +0000 (05:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 23 Oct 2011 05:56:55 +0000 (05:56 +0000)
source/blender/blenlib/intern/path_util.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/render/render_preview.c

index d9176c5f16278fc18bafd9a515027c68cc01615c..d28c1e298204fe8489fdcc3c4d12c6e803134119 100644 (file)
@@ -1257,9 +1257,18 @@ void BLI_make_file_string(const char *relabase, char *string,  const char *dir,
 {
        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 */
index 752677d047df459f26a01e7c0e2952a2ce395f54..45eaa6d0156383eb12c11a0ffcb85bfec36c7628 100644 (file)
@@ -2699,7 +2699,6 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
                }
        }
 
-       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);
 
index 697cddfcee0a5d6b415e67f224dcce35acb3a4b3..af2cd431a10047dae300786202498d4ca7778078 100644 (file)
@@ -122,8 +122,6 @@ ImBuf* get_brush_icon(Brush *brush)
                                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])