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)