Bash-5.2 patch 5: fix crash with null pattern substitution replacement string

This commit is contained in:
Chet Ramey
2022-11-07 11:41:10 -05:00
parent 30e948e80b
commit 7b9954e67a
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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';