[Bf-blender-cvs] [faec666] blender-v2.78-release: Fix T49283: Crash in BKE_ptcache_make_particle_key.

Bastien Montagne noreply at git.blender.org
Wed Sep 14 10:38:36 CEST 2016


Commit: faec666bbea46e5a5e2ae0568ff5c6aea17696a0
Author: Bastien Montagne
Date:   Thu Sep 8 10:24:56 2016 +0200
Branches: blender-v2.78-release
https://developer.blender.org/rBfaec666bbea46e5a5e2ae0568ff5c6aea17696a0

Fix T49283: Crash in BKE_ptcache_make_particle_key.

This is really hack-fix actually, not sure why `get_pointcache_keys_for_time()` seems to assume
it will always find key for given part index at least for current frame, and whether this assumption
is wrong or whether bug happens elsewhere...

Anyway, this is to be wiped out in 2.8, so no point loosing too much time on it, for now merely
returning unchanged (i.e. zero'ed) ParticleKeys in case index2 is invalid. Won't hurt anyway,
even if this did not crash in release builds, would be returning giberish values.

===================================================================

M	source/blender/blenkernel/intern/particle.c

===================================================================

diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 907521c..3eb5751 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -885,6 +885,9 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
 
 			index2 = BKE_ptcache_mem_index_find(pm, index);
 			index1 = BKE_ptcache_mem_index_find(pm->prev, index);
+			if (index2 < 0) {
+				return;
+			}
 
 			BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
 			if (index1 < 0)
@@ -895,6 +898,9 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
 		else if (cache->mem_cache.first) {
 			pm = cache->mem_cache.first;
 			index2 = BKE_ptcache_mem_index_find(pm, index);
+			if (index2 < 0) {
+				return;
+			}
 			BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
 			copy_particle_key(key1, key2, 1);
 		}




More information about the Bf-blender-cvs mailing list