mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
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:
parent
450c3b5626
commit
74137f994f
|
|
@ -34,8 +34,8 @@ TensorId ParseTensorName(StringPiece name) {
|
||||||
// whole name string forms the first part of the tensor name.
|
// whole name string forms the first part of the tensor name.
|
||||||
const char* base = name.data();
|
const char* base = name.data();
|
||||||
const char* p = base + name.size() - 1;
|
const char* p = base + name.size() - 1;
|
||||||
int index = 0;
|
unsigned int index = 0;
|
||||||
int mul = 1;
|
unsigned int mul = 1;
|
||||||
while (p > base && (*p >= '0' && *p <= '9')) {
|
while (p > base && (*p >= '0' && *p <= '9')) {
|
||||||
index += ((*p - '0') * mul);
|
index += ((*p - '0') * mul);
|
||||||
mul *= 10;
|
mul *= 10;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user