Fix crash in Cycles when cancelling render during light tree building

The recursive building has an early output, which could leave the node
without the requested child initialized, causing the access to the left
child to crash later on in the builder function.

Simply add an extra is-canceled check to avoid access of possibly
non-initialized tree structure.

Pull Request: https://projects.blender.org/blender/blender/pulls/112132
This commit is contained in:
Sergey Sharybin
2023-09-08 15:21:54 +02:00
committed by Sergey Sharybin
parent 4de525e757
commit 4b217df080

View File

@@ -406,6 +406,11 @@ LightTreeNode *LightTree::build(Scene *scene, DeviceScene *dscene)
left, root_.get(), num_emissive_triangles, num_local_lights, emitters_.data(), 0, 1);
task_pool.wait_work();
if (progress_.get_cancel()) {
root_.reset();
return nullptr;
}
/* All distant lights are grouped to the right child as a leaf node. */
root_->get_inner().children[right] = create_node(LightTreeMeasure::empty, 1);
for (int i = 0; i < num_distant_lights; i++) {