diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 19 |
2 files changed, 14 insertions, 7 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]; |