diff --git a/pbx.c b/pbx.c
index df1ca7227fc5851c7711b5a49b6fbd33ab78bc32..e454ed786cbc154c12c6553a8381e8c7bf869e7a 100755
--- a/pbx.c
+++ b/pbx.c
@@ -726,7 +726,7 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var,
 		if (!first)
 			first = tmpvar + strlen(tmpvar);
 		*first='\0';
-		pbx_substitute_variables_temp(c,tmpvar,ret,workspace,sizeof(workspace));
+		pbx_substitute_variables_temp(c,tmpvar,ret,workspace,workspacelen - 1);
 		if (!(*ret)) return;
 		offset=atoi(first+1);
 	 	if ((second=strchr(first+1,':'))) {