From 33c90c56213730e2be6fcfae470b5d24574dc90d Mon Sep 17 00:00:00 2001 From: deuce <> Date: Tue, 10 Feb 2009 08:00:02 +0000 Subject: [PATCH] Allocate the line buffer to be the same size as the input buffer. There is no real limit to the number of characters in a logical line since an infinite number of ^A codes can be included. Someone (Angus) has put messages in the wild with a line containing more ^A code bytes than data bytes. :-) --- src/sbbs3/wordwrap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sbbs3/wordwrap.c b/src/sbbs3/wordwrap.c index ca9e33e6b5..2179cc4c34 100644 --- a/src/sbbs3/wordwrap.c +++ b/src/sbbs3/wordwrap.c @@ -183,17 +183,18 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes) int quote_count=0; int old_prefix_bytes=0; int outbuf_size=0; + int inbuf_len=strlen(inbuf); - outbuf_size=strlen(inbuf)*3+1; + outbuf_size=inbuf_len*3+1; if((outbuf=(char*)malloc(outbuf_size))==NULL) return NULL; outp=outbuf; - if((linebuf=(char*)malloc((len*2)+2))==NULL) /* room for ^A codes ToDo: This isn't actually "enough" room */ + if((linebuf=(char*)malloc(inbuf_len+1))==NULL) /* room for ^A codes */ return NULL; if(handle_quotes) { - if((prefix=(char *)malloc((len*2)+2))==NULL) { /* room for ^A codes ToDo: This isn't actually "enough" room */ + if((prefix=(char *)malloc(inbuf_len+1))==NULL) { /* room for ^A codes */ free(linebuf); return NULL; } -- GitLab