From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Fix 49658 more
Date: Sat, 19 Mar 2022 01:33:31 +0100 [thread overview]
Message-ID: <20220319003331.16866-1-mikachu@gmail.com> (raw)
Revert "49658: Fix NULL reference in match code."
This reverts commit 7f240e6aa9f5596a129474ba6294875dfe7ae264.
The above commit causes a crash due to ll being calculated as 0 which
leads to rr being an invalid pointer. Only fixing that to return NULL
when ll is 0 just leads to bck-i-search pattern not working at all,
restoring the condition and adding an explicit NULL check for replstr
seems to work for me.
---
Src/glob.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Src/glob.c b/Src/glob.c
index e31843ad09..aa43253db3 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2599,7 +2599,7 @@ get_match_ret(Imatchdata imd, int b, int e)
e += add;
/* Everything now refers to metafied lengths. */
- if (replstr) {
+ if (replstr || (fl & SUB_LIST)) {
if (fl & SUB_DOSUBST) {
replstr = dupstring(replstr);
singsub(&replstr);
@@ -2618,7 +2618,8 @@ get_match_ret(Imatchdata imd, int b, int e)
addlinknode(imd->repllist, rd);
return imd->mstr;
}
- ll += strlen(replstr);
+ if (replstr)
+ ll += strlen(replstr);
}
if (fl & SUB_MATCH) /* matched portion */
ll += 1 + (e - b);
@@ -2644,6 +2645,9 @@ get_match_ret(Imatchdata imd, int b, int e)
if (bl)
buf[bl - 1] = '\0';
+ if (ll == 0)
+ return NULL;
+
rr = r = (char *) hcalloc(ll);
if (fl & SUB_MATCH) {
--
2.15.1
reply other threads:[~2022-03-19 0:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220319003331.16866-1-mikachu@gmail.com \
--to=mikachu@gmail.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).