summary refs log tree commit diff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2019-07-23 14:45:48 +0200
committerPeter Stephenson <p.stephenson@samsung.com>2019-07-24 17:14:06 +0100
commitf9cd2187875b6f2ebdb9b9a787fac20b2aaf745b (patch)
treee5288dd6561ed41a74db7b664018031dd7ea1126
parenta4f3df89abe283c7ebd877768e3b52f807790586 (diff)
downloadzsh-f9cd2187875b6f2ebdb9b9a787fac20b2aaf745b.tar.gz
zsh-f9cd2187875b6f2ebdb9b9a787fac20b2aaf745b.tar.xz
zsh-f9cd2187875b6f2ebdb9b9a787fac20b2aaf745b.zip
44566: make sure Zle doesn't crash if history entry not found
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_utils.c14
2 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d2eda11ac..3cb564372 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-24  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* Kamil: 44566: Src/Zle/zle_utils.c: make failed searches of
+	history in Zle robust.
+
 2019-07-19  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
 	* 44356: Completion/Unix/Command/_ansible: complete ansible
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 0277d4917..d549b885b 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1607,7 +1607,12 @@ static int
 unapplychange(struct change *ch)
 {
     if(ch->hist != histline) {
-	zle_setline(quietgethist(ch->hist));
+	Histent he = quietgethist(ch->hist);
+	if(!he) {
+	    dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+	    return 1;
+	}
+	zle_setline(he);
 	zlecs = ch->new_cs;
 	return 0;
     }
@@ -1647,7 +1652,12 @@ static int
 applychange(struct change *ch)
 {
     if(ch->hist != histline) {
-	zle_setline(quietgethist(ch->hist));
+	Histent he = quietgethist(ch->hist);
+	if(!he) {
+	    dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+	    return 1;
+	}
+	zle_setline(he);
 	zlecs = ch->old_cs;
 	return 0;
     }