[Bf-blender-cvs] [8c67b8f] master: File Browser: Fix possible bug and some minor tweaks

Julian Eisel noreply at git.blender.org
Sat Jul 11 21:45:19 CEST 2015


Commit: 8c67b8ffe9fdab6698f20a39d5673b720e3d2756
Author: Julian Eisel
Date:   Sat Jul 11 21:37:50 2015 +0200
Branches: master
https://developer.blender.org/rB8c67b8ffe9fdab6698f20a39d5673b720e3d2756

File Browser: Fix possible bug and some minor tweaks

BLI_add_slash appended to a char *, a potential buffer overflow

Also partially removed an assert, which failed after changing file format of a saved image. We need a better way to handle such cases.

===================================================================

M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/file_ops.c

===================================================================

diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 3c09800..9a5ec19 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -160,16 +160,13 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
 		const struct direntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
 		int overwrite_alert = file_draw_check_exists(sfile);
 		const bool is_active_dir = file && file->path && BLI_is_dir(file->path);
-		char *dir_path = (is_active_dir && params->active_file > 0) ? file->path : params->dir;
-
-		BLI_add_slash(dir_path);
 
 		/* callbacks for operator check functions */
 		UI_block_func_set(block, file_draw_check_cb, NULL, NULL);
 
 		but = uiDefBut(block, UI_BTYPE_TEXT, -1, "",
 		               min_x, line1_y, line1_w - chan_offs, btn_h,
-		               dir_path, 0.0, (float)FILE_MAX, 0, 0,
+		               params->dir, 0.0, (float)FILE_MAX, 0, 0,
 		               TIP_("File path"));
 		UI_but_func_complete_set(but, autocomplete_directory, NULL);
 		UI_but_flag_enable(but, UI_BUT_NO_UTF8);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index c54731c..bfe8be9 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1265,15 +1265,10 @@ int file_exec(bContext *C, wmOperator *exec_op)
 	const struct direntry *file = filelist_file(sfile->files, sfile->params->active_file);
 	char filepath[FILE_MAX];
 
-	/* if file is a directory it should be in sync with params->dir, otherwise
-	 * with params->file; file->path might be NULL on link/append */
-	BLI_assert((file == NULL) ||
-	           (file->path == NULL) ||
-	           (STREQ(file->relname, sfile->params->file)) ||
-	           (BLI_is_dir(file->path) && STRPREFIX(file->path, sfile->params->dir)));
-
 	/* directory change */
 	if (file && S_ISDIR(file->type)) {
+		BLI_assert(file->path == NULL || STRPREFIX(file->path, sfile->params->dir));
+
 		if (FILENAME_IS_PARENT(file->relname)) {
 			BLI_parent_dir(sfile->params->dir);
 		}




More information about the Bf-blender-cvs mailing list