Skip to content

Commit e13344b

Browse files
Add null check in getShaderNodes (#2228)
This changelist adds a missing null check in getShaderNodes, handling the edge case of an invalid output string. Previously, this edge case would trigger a crash in MaterialXCore, and now it correctly generates validation warnings and proceeds.
1 parent 7fc041d commit e13344b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/MaterialXCore/Material.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ vector<NodePtr> getShaderNodes(NodePtr materialNode, const string& nodeType, con
5050
vector<OutputPtr> outputs;
5151
if (input->hasOutputString())
5252
{
53-
outputs.push_back(nodeGraph->getOutput(input->getOutputString()));
53+
OutputPtr connectedOutput = nodeGraph->getOutput(input->getOutputString());
54+
if (connectedOutput)
55+
{
56+
outputs.push_back(connectedOutput);
57+
}
5458
}
5559
else
5660
{

0 commit comments

Comments
 (0)