about summary refs log tree commit diff
path: root/Src/hist.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-10-10 23:12:57 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-10-10 23:12:57 -0700
commit605a73e415772a1d74cff39212618c8f1d58297b (patch)
treee40ef7beca0b554d2b968a2fa15f2552833c80d0 /Src/hist.c
parent22c4ea424ce2e8febce04d324c5ec9898f5d534b (diff)
downloadzsh-605a73e415772a1d74cff39212618c8f1d58297b.tar.gz
zsh-605a73e415772a1d74cff39212618c8f1d58297b.tar.xz
zsh-605a73e415772a1d74cff39212618c8f1d58297b.zip
33429: disallow non-integer values for HISTSIZE and SAVEHIST of "fc -p", and fix crash on zero values for same
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 4660fd073..083175640 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1110,8 +1110,11 @@ static void
 putoldhistentryontop(short keep_going)
 {
     static Histent next = NULL;
-    Histent he = keep_going? next : hist_ring->down;
-    next = he->down;
+    Histent he = (keep_going || !hist_ring) ? next : hist_ring->down;
+    if (he)
+	next = he->down;
+    else
+	return;
     if (isset(HISTEXPIREDUPSFIRST) && !(he->node.flags & HIST_DUP)) {
 	static zlong max_unique_ct = 0;
 	if (!keep_going)
@@ -1151,7 +1154,7 @@ prepnexthistent(void)
 	freehistnode(&hist_ring->node);
     }
 
-    if (histlinect < histsiz) {
+    if (histlinect < histsiz || !hist_ring) {
 	he = (Histent)zshcalloc(sizeof *he);
 	if (!hist_ring)
 	    hist_ring = he->up = he->down = he;