Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH v2] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails
- X-seq: zsh-workers 44566
- From: Kamil Dudka <kdudka@xxxxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: [PATCH v2] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails
- Date: Tue, 23 Jul 2019 15:45:48 +0200
- Cc: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, zsh-workers@xxxxxxx
- In-reply-to: <797-1561676485.902916@C-Cf.WCnE.5Cn6>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <797-1561676485.902916@C-Cf.WCnE.5Cn6>
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 | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
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;
}
--
2.20.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author