Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH 02/17: Don't crash when writing out history if HOST is unset



Found by Coverity (Issue 1255793).
---
 Src/hist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Src/hist.c b/Src/hist.c
index a006170..8ff9eff 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) {
-- 
2.2.0.GIT



Messages sorted by: Reverse Date, Date, Thread, Author