Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix a memory leak and potential heap corruption when rotating lines
- X-seq: zsh-workers 44874
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: PATCH: fix a memory leak and potential heap corruption when rotating lines
- Date: Mon, 28 Oct 2019 12:29:23 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=W7cPHNhJXjmKP6MolGnuya4j8j8KnplW+f2z74KyYw4=; b=W7qIXQSQZgWetOTUNVmv56O1ErFe4XqQzAK8cXE81UntNYudu7QuUAqTQROf5ZShhe K3wYy7luyKq8zNZeDHjZCrwnEKOWkKjTSUpYFKcn1W0gRMtNotKYGhcc4v2QUob2hrJz m0ifpnwDKJhzRQNZd3ZnQ/lh/VgUUV0i2/0g+ua2qXZJOSRiTadiTVNuhSrI5H1buqWU Oan3YbJkkufGzUOO4cOnaIrY9XY49hoJnWuKrB/Yuf6HQD6K1VJwP2XU27P9cVHfxBB6 S/3JC4u/VaBVg7iIL5kewek72V0CefMIosr8p6u2kQj8JPE0dfcIn3zup28qWsI1SdTC f3xg==
- 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
I've bumped into this code accidentally while trying to do something
unrelated. It looks wrong to me although there is a good chance I'm
misreading it. I'm attaching a patch that either fixes two bugs,
introduces two new bugs, or does something in between. I'll appreciate
if someone more experienced can take a look at it.
All test pass with this patch and my zsh seems to work fine. I haven't
verified that this code actually runs either during testing or when
I'm using zsh normally.
Roman.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 7cc338ab1..85e55e0d4 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1652,7 +1652,7 @@ zrefresh(void)
zfree(obuf[iln], (winw + 2) * sizeof(**obuf));
for (t0 = iln; t0 != olnct; t0++)
obuf[t0] = obuf[t0 + 1];
- obuf[olnct--] = NULL;
+ obuf[--olnct] = NULL;
}
/* don't try to insert a line if olnct = vmaxln (vmaxln is the number
of lines that have been displayed by this routine) so that we don't
@@ -1662,7 +1662,6 @@ zrefresh(void)
obuf[iln] && !ZR_strncmp(obuf[iln], nbuf[iln + 1], 16)) {
moveto(iln, 0);
tcout(TCINSLINE);
- zfree(obuf[olnct], (winw + 2) * sizeof(**obuf));
for (t0 = olnct; t0 != iln; t0--)
obuf[t0] = obuf[t0 - 1];
obuf[iln] = NULL;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author