summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/hist.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 39599afd5..65c049868 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-01-06  Mikael Magnusson  <mikachu@gmail.com>
 
+	* 34118: Src/hist.c: Don't crash when writing out history if
+	HOST is unset
+
 	* 34114: Src/builtin.c: emulate: Handle aborting from mixed
 	-L/-c correctly
 
diff --git a/Src/hist.c b/Src/hist.c
index a0061707c..8ff9eff82 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2801,7 +2801,8 @@ lockhistfile(char *fn, int keep_trying)
 #ifdef HAVE_LINK
 # ifdef HAVE_SYMLINK
 	sprintf(pidbuf, "/pid-%ld/host-", (long)mypid);
-	lnk = bicat(pidbuf, getsparam("HOST"));
+	lnk = getsparam("HOST");
+	lnk = bicat(pidbuf, lnk ? lnk : "");
 	/* We'll abuse fd as our success flag. */
 	while ((fd = symlink(lnk, lockfile)) < 0) {
 	    if (errno != EEXIST) {