fix [#27526] shared data but different data materials.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 3 Oct 2011 16:55:00 +0000 (16:55 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 3 Oct 2011 16:55:00 +0000 (16:55 +0000)
source/blender/editors/space_buttons/buttons_context.c

index 9d2ac3fd8e2aeadb61a02effa4c14279ca5ad7b7..526859cecd2cd868310b06dd60e9ba167d873a19 100644 (file)
@@ -721,8 +721,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                if(ptr) {
                        Object *ob= ptr->data;
 
-                       if(ob && ob->type && (ob->type<OB_LAMP) && ob->totcol)
-                               CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1);
+                       if(ob && ob->type && (ob->type<OB_LAMP) && ob->totcol) {
+                               /* a valid actcol isn't ensured [#27526] */
+                               int matnr= ob->actcol-1;
+                               if(matnr < 0) matnr= 0;
+                               CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]);
+                       }
                }
 
                return 1;