diff options
author | 2017-09-08 13:37:27 -0700 | |
---|---|---|
committer | 2017-09-08 13:41:28 -0700 | |
commit | 74137f994faad09593ae2daad6251a4ccf72f558 (patch) | |
tree | 5e3f4dc1c66a7db1554eb4596d81f3fed12cf13d /tensorflow/core/graph/tensor_id.cc | |
parent | 450c3b5626030bd02ef6c86f8387cb2ca213dfe5 (diff) |
Fix signed int overflow issue in tensor_id.cc
When a node name has a long numeric suffix, e.g.,
"foo/y_0/gradient_debug_09684b60f2184c67b744721915034528" (as has happened with tfdbg GradientsDebugger),
the parsing algorithm in ParseTensorName() may experience signed int overflow. Replacing the types with "unsigned int" resolves the issue.
PiperOrigin-RevId: 168039195
Diffstat (limited to 'tensorflow/core/graph/tensor_id.cc')
-rw-r--r-- | tensorflow/core/graph/tensor_id.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/core/graph/tensor_id.cc b/tensorflow/core/graph/tensor_id.cc index 985654d027..089ea5e527 100644 --- a/tensorflow/core/graph/tensor_id.cc +++ b/tensorflow/core/graph/tensor_id.cc @@ -34,8 +34,8 @@ TensorId ParseTensorName(StringPiece name) { // whole name string forms the first part of the tensor name. const char* base = name.data(); const char* p = base + name.size() - 1; - int index = 0; - int mul = 1; + unsigned int index = 0; + unsigned int mul = 1; while (p > base && (*p >= '0' && *p <= '9')) { index += ((*p - '0') * mul); mul *= 10; |