Index: source/blender/src/drawtext.c =================================================================== --- source/blender/src/drawtext.c (revision 15697) +++ source/blender/src/drawtext.c (working copy) @@ -189,24 +189,28 @@ Text *text = st->text; TextLine *tmp; char *in_line; - char format[2000], check[200], other[2]; + char *format, check[200], other[2]; unsigned char c; int spot, letter, tabs, mem_amount; - size_t a, b, len; + size_t a, b, len, format_len = 2000; if(!text) return; tmp = text->lines.first; + format = MEM_mallocN(format_len, "formatTemp1"); + while(tmp) { in_line = tmp->line; len = strlen(in_line); /* weak code... but we dont want crashes (ton) */ - if(len>2000-1) { - if (tmp->format) MEM_freeN(tmp->format); - tmp->format= NULL; + if(len>format_len-1) { + MEM_freeN(format); + format_len = len+1; + format = MEM_mallocN(format_len+2, "format temp"); } - else { + + if (format) { spot = 0; tabs = 0; @@ -242,10 +246,16 @@ format[spot] = '\0'; memcpy(tmp->format, format, strlen(format)); if(!(tmp= tmp->next)) { + MEM_freeN(format); return; } else { in_line = tmp->line; len = strlen(in_line); + if(len>format_len-1) { + MEM_freeN(format); + format_len = len+1; + format = MEM_mallocN(format_len+2, "Syntax_formatT1"); + } tabs = 0; for(b = 0; b format, format, strlen(format)); if(!(tmp= tmp->next)) { + MEM_freeN(format); return; } else { in_line = tmp->line; len = strlen(in_line); + if(len>format_len-1) { + MEM_freeN(format); + format_len = len+1; + format = MEM_mallocN(format_len+2, "Syntax_formatT2"); + } for(b = 0; b format, format, strlen(format)); if(!(tmp= tmp->next)) { + MEM_freeN(format); return; } else { in_line = tmp->line; len = strlen(in_line); tabs = 0; + if(len>format_len-1) { + MEM_freeN(format); + format_len = len+1; + format = MEM_mallocN(format_len+2, "Syntax_formatT3"); + } for(b = 0; b format, format, strlen(format)); if(!(tmp= tmp->next)) { + MEM_freeN(format); return; } else { in_line = tmp->line; len = strlen(in_line); + if(len>format_len-1) { + MEM_freeN(format); + format_len = len+1; + format = MEM_mallocN(format_len+2, "Syntax_formatT4"); + } for(b = 0; b next; } + MEM_freeN(format); } static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int draw, int x, int y, char *format) {