From 529a7ba24c9da9fdb1df939ff0fe35c6d27e65df Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 21 Mar 2012 14:12:17 +0300 Subject: [PATCH] Ticket #2754: mceedit can't run w/o file as parameter. Also fixed segfault while run `mc -v ""`. Signed-off-by: Andrew Borodin --- src/filemanager/ext.c | 3 +++ src/filemanager/midnight.c | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index 6fb991420..10de4dde6 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -636,6 +636,9 @@ regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_ int include_target_len; int have_type = 0; /* Flag used by regex_check_type() */ + if (filename_vpath == NULL) + return 0; + /* Check for the special View:%d parameter */ if (strncmp (action, "View:", 5) == 0) { diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 524294840..786013825 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -951,19 +951,23 @@ mc_maybe_editor_or_viewer (void) #ifdef USE_INTERNAL_EDIT case MC_RUN_EDITOR: { - vfs_path_t *param_vpath; + vfs_path_t *vpath = NULL; - param_vpath = vfs_path_from_str (mc_run_param0); - ret = edit_file (param_vpath, mc_args__edit_start_line); - vfs_path_free (param_vpath); + if (mc_run_param0 != NULL && *mc_run_param0 != '\0') + vpath = vfs_path_from_str (mc_run_param0); + + ret = edit_file (vpath, mc_args__edit_start_line); + vfs_path_free (vpath); } break; #endif /* USE_INTERNAL_EDIT */ case MC_RUN_VIEWER: { - vfs_path_t *vpath; + vfs_path_t *vpath = NULL; + + if (mc_run_param0 != NULL && *mc_run_param0 != '\0') + vpath = prepend_cwd_on_local (mc_run_param0); - vpath = prepend_cwd_on_local (mc_run_param0); view_file (vpath, 0, 1); vfs_path_free (vpath); ret = 1;