diff --git a/src/sbbs3/textgen.c b/src/sbbs3/textgen.c
index f7d540e2b3829d3abcaa277c8ce0332923946d01..a7f84f9b4bf5827404722b716d7f6ced1bb93ba6 100644
--- a/src/sbbs3/textgen.c
+++ b/src/sbbs3/textgen.c
@@ -153,8 +153,8 @@ char *format_as_cstr(char *orig)
 	if(!orig)
 		return(NULL);
 	for(in=orig; *in; in++) {
-		if(outpos >= len-5) {
-			len += strlen(in)+5;
+		if(outpos >= len-7) {
+			len += strlen(in)+7;
 			tmp=realloc(ret, len);
 			if(tmp==NULL) {
 				free(ret);
@@ -168,6 +168,8 @@ char *format_as_cstr(char *orig)
 			ret[outpos++]='x';
 			ret[outpos++]=hex[0];
 			ret[outpos++]=hex[1];
+			ret[outpos++]='"';
+			ret[outpos++]='"';
 		}
 		else
 			ret[outpos++]=*in;