zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails
@ 2019-06-26 10:19 Kamil Dudka
       [not found] ` <249696510.1723352.1561545091592@mail2.virginmedia.com>
  2019-06-27 23:01 ` Oliver Kiddle
  0 siblings, 2 replies; 8+ messages in thread
From: Kamil Dudka @ 2019-06-26 10:19 UTC (permalink / raw)
  To: zsh-workers

There is a bug report in Red Hat Bugzilla about zsh crashing on NULL
pointer dereference: https://bugzilla.redhat.com/1722703

I was not able to reproduce the crash myself but the attached patch
should prevent zsh from crashing in this situation.
---
 Src/Zle/zle_utils.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 0277d4917..8081d3adc 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1607,7 +1607,9 @@ static int
 unapplychange(struct change *ch)
 {
     if(ch->hist != histline) {
-	zle_setline(quietgethist(ch->hist));
+	Histent he = quietgethist(ch->hist);
+	if(he)
+	    zle_setline(he);
 	zlecs = ch->new_cs;
 	return 0;
     }
@@ -1647,7 +1649,9 @@ static int
 applychange(struct change *ch)
 {
     if(ch->hist != histline) {
-	zle_setline(quietgethist(ch->hist));
+	Histent he = quietgethist(ch->hist);
+	if(he)
+	    zle_setline(he);
 	zlecs = ch->old_cs;
 	return 0;
     }
-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-26 15:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 10:19 [PATCH] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails Kamil Dudka
     [not found] ` <249696510.1723352.1561545091592@mail2.virginmedia.com>
2019-06-26 11:00   ` Fwd: " Peter Stephenson
2019-06-26 12:07     ` Kamil Dudka
2019-06-27 23:01 ` Oliver Kiddle
2019-06-28  0:20   ` Mikael Magnusson
2019-06-28  8:12   ` Kamil Dudka
2019-07-23 13:45   ` [PATCH v2] " Kamil Dudka
2019-07-26 15:24     ` Kamil Dudka

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).