From fe4cdce6e6c442f502349304ef35f2ac2680a1b0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 19 Oct 2002 17:48:10 +0000 Subject: [PATCH] Handle correctly g_get_home_dir() returning NULL, assume it's the current directory then. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2968 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/core.c | 10 ++++++++-- src/core/misc.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/core/core.c b/src/core/core.c index b11064cb..b4e6d6e0 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -159,6 +159,7 @@ void core_init_paths(int argc, char *argv[]) { "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.irssi)", "PATH" }, { NULL, '\0', 0, NULL } }; + const char *home; char *str; int n, len; @@ -191,8 +192,13 @@ void core_init_paths(int argc, char *argv[]) args_register(options); - if (irssi_dir == NULL) - irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, g_get_home_dir()); + if (irssi_dir == NULL) { + home = g_get_home_dir(); + if (home == NULL) + home = "."; + + irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, home); + } if (irssi_config_file == NULL) irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, irssi_dir); diff --git a/src/core/misc.c b/src/core/misc.c index 01ae0f1d..886c40f1 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -451,9 +451,17 @@ int mkpath(const char *path, int mode) /* convert ~/ to $HOME */ char *convert_home(const char *path) { - return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ? - g_strconcat(g_get_home_dir(), path+1, NULL) : - g_strdup(path); + const char *home; + + if (*path == '~' && (*(path+1) == '/' || *(path+1) == '\0')) { + home = g_get_home_dir(); + if (home == NULL) + home = "."; + + return g_strconcat(home, path+1, NULL); + } else { + return g_strdup(path); + } } int g_istr_equal(gconstpointer v, gconstpointer v2)