Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/font.c2
-rw-r--r--source/blender/blenkernel/intern/material.c19
-rw-r--r--source/blender/editors/curve/editfont.c9
3 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 4c8d0cf998d..9c01b35b91a 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -546,7 +546,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
nu2->knotsu = nu2->knotsv = NULL;
nu2->flag= CU_SMOOTH;
nu2->charidx = charidx;
- if (info->mat_nr) {
+ if (info->mat_nr > 0) {
nu2->mat_nr= info->mat_nr-1;
}
else {
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index ed9be989dbd..ebd05ab9bf8 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1105,8 +1105,17 @@ int object_remove_material_slot(Object *ob)
short *totcolp;
short a, actcol;
- if(ob==NULL || ob->totcol==0) return FALSE;
-
+ if (ob==NULL || ob->totcol==0) {
+ return FALSE;
+ }
+
+ /* this should never happen and used to crash */
+ if (ob->actcol <= 0) {
+ printf("%s: invalid material index %d, report a bug!\n", __func__, ob->actcol);
+ BLI_assert(0);
+ return FALSE;
+ }
+
/* take a mesh/curve/mball as starting point, remove 1 index,
* AND with all objects that share the ob->data
*
@@ -1119,10 +1128,8 @@ int object_remove_material_slot(Object *ob)
if(*matarar==NULL) return FALSE;
/* we delete the actcol */
- if(ob->totcol) {
- mao= (*matarar)[ob->actcol-1];
- if(mao) mao->id.us--;
- }
+ mao= (*matarar)[ob->actcol-1];
+ if(mao) mao->id.us--;
for(a=ob->actcol; a<ob->totcol; a++)
(*matarar)[a-1]= (*matarar)[a];
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);