Blob Blame History Raw
From 15c190164c375cfe1772ebec92b544ca26a60e28 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Tue, 23 Jul 2019 14:45:48 +0200
Subject: [PATCH 1/2] 44566: make sure Zle doesn't crash if history entry not
 found

Upstream-commit: f9cd2187875b6f2ebdb9b9a787fac20b2aaf745b
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 Src/Zle/zle_utils.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index c6df3d8..633f593 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;
     }
-- 
2.20.1


From 10dedc96ce0de43372add239f8256e259ca1e04a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Fri, 26 Jul 2019 17:24:59 +0200
Subject: [PATCH 2/2] 44582: Fix foregoing commit to use DPUTS() better

Upstream-commit: d6a9e222ec6b006c09d6f84beae6ef488a19b214
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 Src/Zle/zle_utils.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 633f593..29dba08 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1608,10 +1608,9 @@ unapplychange(struct change *ch)
 {
     if(ch->hist != histline) {
 	Histent he = quietgethist(ch->hist);
-	if(!he) {
-	    dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+	DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL");
+	if(he == NULL)
 	    return 1;
-	}
 	zle_setline(he);
 	zlecs = ch->new_cs;
 	return 0;
@@ -1653,10 +1652,9 @@ applychange(struct change *ch)
 {
     if(ch->hist != histline) {
 	Histent he = quietgethist(ch->hist);
-	if(!he) {
-	    dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+	DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL");
+	if(he == NULL)
 	    return 1;
-	}
 	zle_setline(he);
 	zlecs = ch->old_cs;
 	return 0;
-- 
2.20.1