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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-09-23 16:57:39 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-09-26 11:51:51 +0300
commitdaa1487425b105dbe74c2e784ca52ea03ed7d874 (patch)
treed1a5e56794d05809f6c94392a5047ae7c12077e5 /source
parentabc8810911c77ee57a9134dd4e015c6bc182bfe7 (diff)
Cycles: Prevent crash in special cases when object has less slots than mesh
This is something what was guaranteed in give_current_material(), just copied some range checking logic from there. Not sure what would be a proper fix here tho.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/mesh.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index ba3aef81514..49e35585995 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -2368,8 +2368,12 @@ Mesh *BKE_mesh_new_from_object(
if (tmpcu->mat) {
for (i = tmpcu->totcol; i-- > 0; ) {
/* are we an object material or data based? */
-
- tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
+ if (ob->matbits[i] && i >= ob->totcol) {
+ tmpmesh->mat[i] = NULL;
+ }
+ else {
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
+ }
if (do_mat_id_us && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
@@ -2388,7 +2392,12 @@ Mesh *BKE_mesh_new_from_object(
if (tmpmb->mat) {
for (i = tmpmb->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpmb->mat[i];
+ if (ob->matbits[i] && i >= ob->totcol) {
+ tmpmesh->mat[i] = NULL;
+ }
+ else {
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpmb->mat[i];
+ }
if (do_mat_id_us && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
@@ -2408,7 +2417,12 @@ Mesh *BKE_mesh_new_from_object(
if (origmesh->mat) {
for (i = origmesh->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
+ if (ob->matbits[i] && i >= ob->totcol) {
+ tmpmesh->mat[i] = NULL;
+ }
+ else {
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
+ }
if (do_mat_id_us && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);