Fix: Compositor: Potential crash if no active context is found

This is related to #140381, where the symptom of the bug was a crash
caused by an undefined behavior. In that case, setting a valid active
viewer key was the proper fix. However,
`find_active_context_recursive()` could return `nullptr` in theory so
the same problem might occur in the future.

The commit resolves the undefined behavior by avoiding the
dereferencing of a null pointer.

Pull Request: https://projects.blender.org/blender/blender/pulls/141270
This commit is contained in:
Habib Gahbiche
2025-07-08 11:34:11 +02:00
parent 7007ffaad5
commit 75333e0ea5

View File

@@ -350,7 +350,14 @@ const DTreeContext &DerivedNodeTree::active_context() const
return root_context();
}
return *find_active_context_recursive(&root_context());
const DTreeContext *found_context = find_active_context_recursive(&root_context());
if (found_context == nullptr) {
/* There should always be a valid active context. */
BLI_assert_unreachable();
return root_context();
}
return *found_context;
}
/* Each nested node group gets its own cluster. Just as node groups, clusters can be nested. */