about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 2bc6d75a6..cee2e6e5c 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3477,7 +3477,11 @@ modify(char **str, char **ptr)
 			chuck(tt--);
 		*ptr1end = sav1;
 		*ptr3 = sav;
-		*ptr = ptr3 + charlen - 1;
+		*ptr = ptr3 - 1;
+		if (*ptr3) {
+		    /* Final terminator is optional. */
+		    *ptr += charlen;
+		}
 		break;
 
 	    case '&':