Skip to content

Commit 97282c6

Browse files
Prevent a crash due to heap OOB write in grappler.
PiperOrigin-RevId: 408318417 Change-Id: If095feb8c001e3a8ac4a85b7387b81e8309df47d
1 parent 557a094 commit 97282c6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tensorflow/core/grappler/costs/graph_properties.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,12 @@ class SymbolicShapeRefiner {
11341134
GetUnknownOutputShape(node, output_port);
11351135
InferenceContext* ctx = GetContext(node);
11361136
if (ctx == nullptr) {
1137-
return errors::InvalidArgument("Missing context");
1137+
return errors::InvalidArgument("SetUnknownShape: Missing context");
1138+
}
1139+
if (output_port < 0 || output_port >= ctx->num_outputs()) {
1140+
return errors::InvalidArgument(
1141+
"SetUnknownShape: output_port must be in [0, ", ctx->num_outputs(),
1142+
") but was ", output_port);
11381143
}
11391144
ctx->set_output(output_port, shape);
11401145
return Status::OK();

0 commit comments

Comments
 (0)