From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: zsh-workers@zsh.org
Subject: Re: Complex config triggering Segfault in pattern matching code.
Date: Mon, 29 Dec 2014 00:57:00 +0000 [thread overview]
Message-ID: <20141229005700.GB1737@tarsus.local2> (raw)
In-Reply-To: <20141218190924.0f08548b@pws-pc.ntlworld.com>
Peter Stephenson wrote on Thu, Dec 18, 2014 at 19:09:24 +0000:
> @@ -450,10 +451,15 @@ set_region_highlight(UNUSED(Param pm), char **aval)
> len = aval ? arrlen(aval) : 0;
> if (n_region_highlights != len + N_SPECIAL_HIGHLIGHTS) {
> /* no null termination, but include special highlighting at start */
> - n_region_highlights = len + N_SPECIAL_HIGHLIGHTS;
> + int newsize = len + N_SPECIAL_HIGHLIGHTS
> + int diffsize = newsize - n_region_highlights;
> region_highlights = (struct region_highlight *)
> zrealloc(region_highlights,
> - sizeof(struct region_highlight) * n_region_highlights);
> + sizeof(struct region_highlight) * newsize);
> + if (diffsize > 0)
> + memset(region_highlights + newsize, 0,
> + sizeof(struct region_highlight) * diffsize);
> + n_region_highlights = newsize;
> }
>
The arguments to memset() are wrong:
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index c146e46..fe33799 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -457,7 +457,7 @@ set_region_highlight(UNUSED(Param pm), char **aval)
zrealloc(region_highlights,
sizeof(struct region_highlight) * newsize);
if (diffsize > 0)
- memset(region_highlights + newsize, 0,
+ memset(region_highlights + newsize - diffsize, 0,
sizeof(struct region_highlight) * diffsize);
n_region_highlights = newsize;
}
(Found via glibc's "glibc detected memory corruption" runtime check.)
Cheers,
Daniel
> if (!aval)
>
> --
> Peter Stephenson <p.w.stephenson@ntlworld.com>
> Web page now at http://homepage.ntlworld.com/p.w.stephenson/
prev parent reply other threads:[~2014-12-29 0:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-13 19:49 Jonathan H
2014-12-13 23:28 ` Bart Schaefer
2014-12-13 23:36 ` Jonathan H
2014-12-14 4:40 ` Bart Schaefer
2014-12-14 18:20 ` Peter Stephenson
2014-12-14 18:43 ` Bart Schaefer
2014-12-15 21:20 ` Jonathan H
2014-12-15 23:39 ` Bart Schaefer
2014-12-16 20:58 ` Peter Stephenson
2014-12-17 17:18 ` Jonathan H
2014-12-18 6:14 ` Bart Schaefer
2014-12-18 19:09 ` Peter Stephenson
2014-12-18 19:34 ` Peter Stephenson
2014-12-29 0:57 ` Daniel Shahaf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141229005700.GB1737@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--cc=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).