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:
authorCampbell Barton <ideasman42@gmail.com>2011-10-12 03:08:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-12 03:08:17 +0400
commit4750f24663cc4077861de80a38dcd21af781f30d (patch)
tree1d6a295977937272be7a85cc98b494431bac3dd5 /source/blender/blenkernel
parent6b2dd62c64638b97ae9b3164a69dc143a31447cd (diff)
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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/font.c2
-rw-r--r--source/blender/blenkernel/intern/material.c19
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];