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
This commit is contained in:
Shanqing Cai 2017-09-08 13:37:27 -07:00 committed by TensorFlower Gardener
parent 450c3b5626
commit 74137f994f

View File

@ -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;