From 4750f24663cc4077861de80a38dcd21af781f30d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Oct 2011 23:08:17 +0000 Subject: fix for crash caused by invalid active material index while editing text. also added some better error checking in object_remove_material_slot() so it will print an error rather then crashing if this case ever happens again. --- source/blender/editors/curve/editfont.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/curve') diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index d8257c524c1..19892d2c1ee 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -264,9 +264,16 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re EditFont *ef= cu->editfont; cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0]; - if(obedit->totcol>0) + if(obedit->totcol > 0) { obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr; + /* since this array is calloc'd, it can be 0 even though we try ensure + * (mat_nr > 0) almost everywhere */ + if (obedit->actcol < 1) { + obedit->actcol= 1; + } + } + if(mode == FO_EDIT) update_string(cu); -- cgit v1.2.3