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.
This commit is contained in:
parent
7b1489b93b
commit
8c67b8ffe9
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue