summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Src/hist.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/hist.c b/Src/hist.c
index e5de9572e..a1bc73636 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2330,8 +2330,10 @@ savehistfile(char *fn, int err, int writeflags)
 		} else {
 		    /* We renamed over the locked HISTFILE, so close fd.
 		     * If we do more writing, we'll get a lock then. */
-		    close(flock_fd);
-		    flock_fd = -1;
+		    if (flock_fd >= 0) {
+			close(flock_fd);
+			flock_fd = -1;
+		    }
 #endif
 		}
 	    }