Avoid undefined behavior by checking for null Operation in TF_Input/TF_Output
PiperOrigin-RevId: 318082756 Change-Id: I5b5e9bc716cf159f22a4b89083e00efb93d9fecb
This commit is contained in:
parent
cb7907d992
commit
a17858f3cc
@ -54,7 +54,7 @@ Status ProcessInputs(
|
||||
TF_EXCLUSIVE_LOCKS_REQUIRED(fn_body->mu) {
|
||||
input_tensors->reserve(ninputs);
|
||||
for (int i = 0; i < ninputs; ++i) {
|
||||
Node* node = &inputs[i].oper->node;
|
||||
Node* node = inputs[i].oper ? &inputs[i].oper->node : nullptr;
|
||||
int idx = inputs[i].index;
|
||||
|
||||
TF_RETURN_WITH_CONTEXT_IF_ERROR(
|
||||
@ -90,7 +90,7 @@ Status ProcessOutputs(const TF_Graph* fn_body, const char* fn_name,
|
||||
TF_EXCLUSIVE_LOCKS_REQUIRED(fn_body->mu) {
|
||||
output_tensors->reserve(noutputs);
|
||||
for (int i = 0; i < noutputs; ++i) {
|
||||
Node* node = &outputs[i].oper->node;
|
||||
Node* node = outputs[i].oper ? &outputs[i].oper->node : nullptr;
|
||||
int idx = outputs[i].index;
|
||||
TF_RETURN_WITH_CONTEXT_IF_ERROR(
|
||||
fn_body->graph.IsValidOutputTensor(node, idx),
|
||||
|
Loading…
Reference in New Issue
Block a user