2.5
authorTon Roosendaal <ton@blender.org>
Mon, 15 Jun 2009 09:54:37 +0000 (09:54 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 15 Jun 2009 09:54:37 +0000 (09:54 +0000)
Text Object: editmode suffered wrong allocation and reading from wrong
memory, causing crashes when typing more than a few chars.

source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/font.c
source/blender/editors/curve/editfont.c

index fab9669d55fa2b8f48044b57a5e3114385b809e8..7dd868278f4c2f71716fcd8c7aec88d9aeb44a06 100644 (file)
@@ -155,7 +155,7 @@ Curve *add_curve(char *name, int type)
                cu->str= MEM_mallocN(12, "str");
                strcpy(cu->str, "Text");
                cu->pos= 4;
-               cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo");
+               cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new");
                cu->totbox= cu->actbox= 1;
                cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox");
                cu->tb[0].w = cu->tb[0].h = 0.0;
index c3cf6e06c0943e730409a346be102163c5312e33..60a7ffc28d9923ac14f2f9e84c0b088aff8d3855 100644 (file)
@@ -682,7 +682,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                cu->ulheight = 0.05;
        
        if (cu->strinfo==NULL)  /* old file */
-               cu->strinfo = MEM_callocN((slen+1) * sizeof(CharInfo), "strinfo compat");
+               cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat");
        
        custrinfo= cu->strinfo;
        if (cu->editfont)
@@ -1145,7 +1145,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                if (cu->sepchar==0) {
                        for (i= 0; i<slen; i++) {
                                cha = (uintptr_t) mem[i];
-                               info = &(cu->strinfo[i]);
+                               info = &(custrinfo[i]);
                                if (info->mat_nr > (ob->totcol)) {
                                        /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */
                                        info->mat_nr = 0;
index 1b2c8ea6b1105c994c079e0494c3ba69af038219..0fb6fb8cb90b43267b62a0b0b2bef65ea450cc24 100644 (file)
@@ -1407,7 +1407,7 @@ void make_editText(Object *obedit)
                ef->copybuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditcopybuf");
                ef->copybufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditcopybufinfo");      
                ef->oldstr= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf");
-               ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf");
+               ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "oldstrbuf");
        }
        
        // Convert the original text to wchar_t