summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2022-11-07 11:41:10 -0500
committerChet Ramey <chet.ramey@case.edu>2022-11-07 11:41:10 -0500
commit7b9954e67aab9fed742becbfd77dcb1cbcf423bc (patch)
treec922f6d3d6d66dc72038a23db55f3480d18263ab
parent30e948e80b1322c295a19246786dea779ca8c81a (diff)
downloadbash-7b9954e67aab9fed742becbfd77dcb1cbcf423bc.tar.gz
Bash-5.2 patch 5: fix crash with null pattern substitution replacement string
-rw-r--r--patchlevel.h2
-rw-r--r--subst.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/patchlevel.h b/patchlevel.h
index 16233d5a..c2610416 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 4
+#define PATCHLEVEL 5
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index 295d3aad..b22fc64b 100644
--- a/subst.c
+++ b/subst.c
@@ -8965,7 +8965,8 @@ pat_subst (string, pat, rep, mflags)
return (ret);
}
else if (*string == 0 && (match_pattern (string, pat, mtype, &s, &e) != 0))
- return ((mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2) : savestring (rep));
+ return (mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2)
+ : (rep ? savestring (rep) : savestring (""));
ret = (char *)xmalloc (rsize = 64);
ret[0] = '\0';