Fix possible segfault with ShapeHandle.

PiperOrigin-RevId: 283605264
Change-Id: I4531583f987439338f3207697f388fd1c74ccf23
This commit is contained in:
A. Unique TensorFlower 2019-12-03 13:03:44 -08:00 committed by TensorFlower Gardener
parent 08266e2d23
commit 0c3af9326f

View File

@ -306,7 +306,7 @@ class InferenceContext {
// idx can be negative for an offset from end of dimensions.
// idx must be in the range [-1 * s.rank, s.rank).
DimensionHandle Dim(ShapeHandle s, int64 idx) {
if (s->rank_ == kUnknownRank) {
if (!s.Handle() || s->rank_ == kUnknownRank) {
return UnknownDim();
}
return DimKnownRank(s, idx);