about summary refs log tree commit diff
path: root/Src/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Src/hist.c b/Src/hist.c
index f3979dfc0..55131f06e 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1129,7 +1129,13 @@ hend(Eprog prog)
     if (hist_ignore_all_dups != isset(HISTIGNOREALLDUPS)
      && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0)
 	histremovedups();
-    
+
+    /*
+     * Added the following in case the test "hptr < chline + 1"
+     * is more than just paranoia.
+     */
+    DPUTS(hptr < chline, "History end pointer off start of line");
+    *hptr = '\0';
     addlinknode(hookargs, "zshaddhistory");
     addlinknode(hookargs, chline);
     callhookfunc("zshaddhistory", hookargs, 1, &hookret);
@@ -1144,7 +1150,6 @@ hend(Eprog prog)
     if (hptr < chline + 1)
 	save = 0;
     else {
-	*hptr = '\0';
 	if (hptr[-1] == '\n') {
 	    if (chline[1]) {
 		*--hptr = '\0';