fix for crash when psys_get_dupli_texture() was called on a subsurf mesh with simplif...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Jul 2010 20:35:10 +0000 (20:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Jul 2010 20:35:10 +0000 (20:35 +0000)
source/blender/blenkernel/intern/particle.c

index f33ac2a..96c0afe 100644 (file)
@@ -4257,8 +4257,13 @@ void psys_get_dupli_texture(Object *ob, ParticleSettings *part, ParticleSystemMo
                        num= pa->num_dmcache;
 
                        if(num == DMCACHE_NOTFOUND)
-                               if(pa->num < psmd->dm->getNumFaces(psmd->dm))
-                                       num= pa->num;
+                               num= pa->num;
+
+                       if (num >= psmd->dm->getNumFaces(psmd->dm)) {
+                               /* happens when simplify is enabled
+                                * gives invalid coords but would crash otherwise */
+                               num= DMCACHE_NOTFOUND;
+                       }
 
                        if(mtface && num != DMCACHE_NOTFOUND) {
                                mface= psmd->dm->getFaceData(psmd->dm, num, CD_MFACE);