Fix #107420: crash getting PTCacheID when baking scene rigid body world #107536

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:107420_a into main 2023-05-02 17:56:23 +02:00

1 Commits

Author SHA1 Message Date
Philipp Oeser 5157303dba Fix #107420: crash getting PTCacheID when baking scene rigid body world
`ptcache_baker_create` falsely assumed the PointCache owner id is always
an **object**, but when baking rigid body world it is a **scene**. Code
would cast the ID to an object and passed that to `BKE_ptcache_id_find` /
`BKE_ptcache_ids_from_object` (which can get terribly wrong -- reading
_something_ on the scene as something from the assumed object).

Prior to f61ff22967 this was less likely to be a problem, but that
commit introduced a `DrawDataList` into the `struct Scene. In the file
from the report, this would lead to `foreach_object_particle_ptcache`
now recognizing garbage memory as a particle system, accessing its
`ParticleSettings` `phystype` would then crash (buffer-overflow).

Now pass a NULL object to `BKE_ptcache_id_find` in case we are having a
scene, following code still handles rigid bodies just fine (the scene is
actually passed separately as well).
2023-05-02 13:01:33 +02:00