Skip to content

Commit

Permalink
Prevent null pointer dereference in constant folding.
Browse files Browse the repository at this point in the history
Under certain conditions, an invalid protobuf saved model with invalid nodes would be loaded. During optimization phase, Grappler optimizer will then dereference a null pointer.

PiperOrigin-RevId: 409683530
Change-Id: I1f10340a7ec384bc9bc587300390f1078cf5caa0
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Nov 13, 2021
1 parent 7a6a727 commit 0a365c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tensorflow/core/grappler/optimizers/constant_folding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,9 @@ bool ConstantFolding::MulConvPushDown(GraphDef* optimized_graph, NodeDef* node,

NodeDef* mul_left_child = node_map_->GetNode(node->input(0));
NodeDef* mul_right_child = node_map_->GetNode(node->input(1));
if (mul_left_child == nullptr || mul_right_child == nullptr) {
return false;
}
// One child must be constant, and the second must be Conv op.
const bool left_child_is_constant = IsReallyConstant(*mul_left_child);
const bool right_child_is_constant = IsReallyConstant(*mul_right_child);
Expand Down

0 comments on commit 0a365c0

Please # to comment.