From: Chet Ramey Date: Mon, 7 Nov 2022 16:41:10 +0000 (-0500) Subject: Bash-5.2 patch 5: fix crash with null pattern substitution replacement string X-Git-Tag: bash-5.3-alpha~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b9954e67aab9fed742becbfd77dcb1cbcf423bc;p=thirdparty%2Fbash.git Bash-5.2 patch 5: fix crash with null pattern substitution replacement string --- diff --git a/patchlevel.h b/patchlevel.h index 16233d5a5..c2610416f 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 295d3aad5..b22fc64be 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';