about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 52afd6484..dc2052ee0 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4689,7 +4689,8 @@ modify(char **str, char **ptr, int inbrace)
 		    case 'S':
 			hsubpatopt = (c == 'S');
 			if (hsubl && hsubr)
-			    subst(&copy, hsubl, hsubr, gbal, hsubpatopt);
+			    subst(&copy, dupstring(hsubl), dupstring(hsubr),
+				  gbal, hsubpatopt);
 			break;
 		    case 'q':
 			copy = quotestring(copy, QT_BACKSLASH_SHOWNULL);
@@ -4777,7 +4778,8 @@ modify(char **str, char **ptr, int inbrace)
 		case 'S':
 		    hsubpatopt = (c == 'S');
 		    if (hsubl && hsubr)
-			subst(str, hsubl, hsubr, gbal, hsubpatopt);
+			subst(str, dupstring(hsubl), dupstring(hsubr),
+			      gbal, hsubpatopt);
 		    break;
 		case 'q':
 		    *str = quotestring(*str, QT_BACKSLASH);