From: ewt Date: Mon, 29 Oct 2001 23:09:48 +0000 (+0000) Subject: msw! didn't allocate enough memory X-Git-Tag: r0-50-35~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd04625ef8d65b8efc0aad231df77db9e969f790;p=thirdparty%2Fnewt.git msw! didn't allocate enough memory --- diff --git a/textbox.c b/textbox.c index dc42dc5..06fa47c 100644 --- a/textbox.c +++ b/textbox.c @@ -159,8 +159,8 @@ static void doReflow(const char * text, char ** resultPtr, int width, int kanji = 0; if (resultPtr) { - /* XXX I think this will work */ - result = malloc(strlen(text) + (strlen(text) / width) + 2); + /* worst case is a \n after every character */ + result = malloc((strlen(text) * 2) + 1); *result = '\0'; } @@ -227,6 +227,8 @@ static void doReflow(const char * text, char ** resultPtr, int width, } } + result = realloc(result, strlen(result) + 1); + if (badness) *badness = howbad; if (resultPtr) *resultPtr = result; if (heightPtr) *heightPtr = height;