diff --git a/env.cpp b/env.cpp index b5e639f50..53d0659b8 100644 --- a/env.cpp +++ b/env.cpp @@ -656,8 +656,11 @@ void env_init() env_set( L"version", version, ENV_GLOBAL ); free( version ); - wchar_t * fishd_dir = const_cast(env_get_string( L"FISHD_SOCKET_DIR").c_str()); - wchar_t * user_dir = const_cast(env_get_string( L"USER" ).c_str()); + const wcstring fishd_dir_wstr = env_get_string( L"FISHD_SOCKET_DIR"); + const wcstring user_dir_wstr = env_get_string( L"USER" ); + + wchar_t * fishd_dir = fishd_dir_wstr.empty()?NULL:const_cast(fishd_dir_wstr.c_str()); + wchar_t * user_dir = user_dir_wstr.empty()?NULL:const_cast(user_dir_wstr.c_str()); env_universal_init(fishd_dir , user_dir , &start_fishd,