diff --git a/src/switch_channel.c b/src/switch_channel.c
index 084657a8d1..872e568bf9 100644
--- a/src/switch_channel.c
+++ b/src/switch_channel.c
@@ -1633,7 +1633,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
 	nv = 0;
 	olen = strlen(in) + 1;
 	indup = strdup(in);
-	endof_indup = end_of_p(indup);
+	endof_indup = end_of_p(indup) + 1;
 
 	if ((data = malloc(olen))) {
 		memset(data, 0, olen);
diff --git a/src/switch_event.c b/src/switch_event.c
index 451b53851a..ce8c4da866 100644
--- a/src/switch_event.c
+++ b/src/switch_event.c
@@ -1219,7 +1219,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const
 	nv = 0;
 	olen = strlen(in) + 1;
 	indup = strdup(in);
-	endof_indup = end_of_p(indup);
+	endof_indup = end_of_p(indup) + 1;
 
 	if ((data = malloc(olen))) {
 		memset(data, 0, olen);