Page Menu
Home
Search
Configure Global Search
Log In
Files
F7330
text.bug.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Campbell Barton (campbellbarton)
Nov 13 2013, 1:46 PM
Size
3 KB
Subscribers
None
text.bug.patch
View Options
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 <len; b++) {
c = (unsigned char) in_line[b];
@@ -287,10 +297,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_formatT2");
+ }
for(b = 0; b <len; b++) {
c = (unsigned char) in_line[b];
if(c == '\t') {
@@ -335,11 +351,17 @@
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);
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 <len; b++) {
c = (unsigned char) in_line[b];
if(c == '\t') {
@@ -380,10 +402,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_formatT4");
+ }
for(b = 0; b <len; b++) {
c = (unsigned char) in_line[b];
if(c == '\t') {
@@ -527,6 +555,7 @@
tmp = tmp->next;
}
+ MEM_freeN(format);
}
static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int draw, int x, int y, char *format) {
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8a/5b/9994a7f375346c1705760ffebbce
Event Timeline
Log In to Comment