EEVEE-Next: Fix use after free when syncing curves/point clouds.
In `SyncModule::sync_curves/sync_point_cloud` the material variable can be used after it has been freed. The cause is that cryptomatte can request a new material, which might trigger a relocation of the references material. This PR fixes this by doing the shadow sync before the cryptomatte sync. Pull Request: https://projects.blender.org/blender/blender/pulls/121909
This commit is contained in:
@@ -314,8 +314,7 @@ void SyncModule::sync_point_cloud(Object *ob,
|
||||
drawcall_add(material.reflection_probe_shading);
|
||||
|
||||
inst_.cryptomatte.sync_object(ob, res_handle);
|
||||
GPUMaterial *gpu_material =
|
||||
inst_.materials.material_array_get(ob, has_motion).gpu_materials[material_slot - 1];
|
||||
GPUMaterial *gpu_material = material.shading.gpumat;
|
||||
::Material *mat = GPU_material_get_material(gpu_material);
|
||||
inst_.cryptomatte.sync_material(mat);
|
||||
|
||||
@@ -579,8 +578,7 @@ void SyncModule::sync_curves(Object *ob,
|
||||
drawcall_add(material.reflection_probe_shading);
|
||||
|
||||
inst_.cryptomatte.sync_object(ob, res_handle);
|
||||
GPUMaterial *gpu_material =
|
||||
inst_.materials.material_array_get(ob, has_motion).gpu_materials[mat_nr - 1];
|
||||
GPUMaterial *gpu_material = material.shading.gpumat;
|
||||
::Material *mat = GPU_material_get_material(gpu_material);
|
||||
inst_.cryptomatte.sync_material(mat);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user