]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.2 patch 5: fix crash with null pattern substitution replacement string
authorChet Ramey <chet.ramey@case.edu>
Mon, 7 Nov 2022 16:41:10 +0000 (11:41 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 7 Nov 2022 16:41:10 +0000 (11:41 -0500)
patchlevel.h
subst.c

index 16233d5a59cc51cfec37aa0204005cad3c71fb49..c2610416fed1ba5a125ed3534b8485c73fba6da3 100644 (file)
@@ -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 295d3aad52e0f177b37661457ae6fb84e8c67897..b22fc64be2cb12448f902651fdd376b9b787ea8e 100644 (file)
--- 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';