aboutsummaryrefslogtreecommitdiffstats
path: root/rc.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2018-01-20 16:29:10 +0000
committerTatsuya Kinoshita <tats@debian.org>2018-01-21 01:34:11 +0000
commit18dcbadf2771cdb0c18509b14e4e73505b242753 (patch)
tree1ea6237b8f2c596d86d14f92d72716b579dfed07 /rc.c
parentSuppress error messages when ~/.w3m is unwritable (diff)
downloadw3m-18dcbadf2771cdb0c18509b14e4e73505b242753.tar.gz
w3m-18dcbadf2771cdb0c18509b14e4e73505b242753.zip
Make temporary directory safely when ~/.w3m is unwritable
Diffstat (limited to 'rc.c')
-rw-r--r--rc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/rc.c b/rc.c
index eb562c9..3fd84ef 100644
--- a/rc.c
+++ b/rc.c
@@ -1330,6 +1330,11 @@ init_rc(void)
((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') &&
((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0'))
tmp_dir = "/tmp";
+#ifdef HAVE_MKDTEMP
+ tmp_dir = mkdtemp(Strnew_m_charp(tmp_dir, "/w3m-XXXXXX", NULL)->ptr);
+ if (tmp_dir == NULL)
+ tmp_dir = rc_dir;
+#endif
create_option_search_table();
goto open_rc;
}