Ticket #3093: mc-initial-dir-from-PWD-part2.patch

File mc-initial-dir-from-PWD-part2.patch, 2.0 KB (added by egmont, 10 years ago)

fix segfault

  • src/main.c

    diff --git a/src/main.c b/src/main.c
    index 76932b9..75b5b16 100644
    a b main (int argc, char *argv[]) 
    293293    vfs_init (); 
    294294    vfs_plugins_init (); 
    295295 
     296    load_setup (); 
     297 
     298    /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */ 
     299    vfs_setup_work_dir (); 
     300 
     301    /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */ 
     302    { 
     303        char *buffer; 
     304        vfs_path_t *vpath; 
     305 
     306        buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", "."); 
     307        vpath = vfs_path_from_str (buffer); 
     308        if (vfs_file_is_local (vpath)) 
     309            saved_other_dir = buffer; 
     310        else 
     311            g_free (buffer); 
     312        vfs_path_free (vpath); 
     313    } 
     314 
    296315    /* Set up temporary directory after VFS initialization */ 
    297316    mc_tmpdir (); 
    298317 
    299     /* do this after vfs initialization due to mc_setctl() call in mc_setup_by_args() */ 
     318    /* do this after vfs initialization and vfs working directory setup 
     319       due to mc_setctl() and mcedit_arg_vpath_new() calls in mc_setup_by_args() */ 
    300320    if (!mc_setup_by_args (argc, argv, &error)) 
    301321    { 
    302322        vfs_shut (); 
    main (int argc, char *argv[]) 
    337357    /* FIXME: Should be removed and LINES and COLS computed on subshell */ 
    338358    tty_init (!mc_args__nomouse, mc_global.tty.xterm_flag); 
    339359 
    340     load_setup (); 
    341  
    342     /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */ 
    343     vfs_setup_work_dir (); 
    344  
    345     /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */ 
    346     { 
    347         char *buffer; 
    348         vfs_path_t *vpath; 
    349  
    350         buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", "."); 
    351         vpath = vfs_path_from_str (buffer); 
    352         if (vfs_file_is_local (vpath)) 
    353             saved_other_dir = buffer; 
    354         else 
    355             g_free (buffer); 
    356         vfs_path_free (vpath); 
    357     } 
    358  
    359360    /* start check mc_global.display_codepage and mc_global.source_codepage */ 
    360361    check_codeset (); 
    361362