diff options
author | 2017-03-30 11:52:01 -0800 | |
---|---|---|
committer | 2017-03-30 13:05:46 -0700 | |
commit | 63b2f999d3f22cfe915b89103faa1b0a1b1b7617 (patch) | |
tree | 593eed2cb1ab751cf9574e0a8ba804d20f661d93 /tensorflow/core/lib/io | |
parent | 052e207e4f1076ac6b7464c01a67ecf4f986766d (diff) |
Enable snappy.
Fix implicit type cast bug in snappy_inputbuffer. Bitwise OR of unsigned int and signed char can cause unexpected issues so we explicitly cast it to unsigned char.
Change: 151737878
Diffstat (limited to 'tensorflow/core/lib/io')
-rw-r--r-- | tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc b/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc index ac1ba72b16..39202e9237 100644 --- a/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc +++ b/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc @@ -129,7 +129,10 @@ Status SnappyInputBuffer::ReadCompressedBlockLength(uint32* length) { size_t readable = std::min(bytes_to_read, avail_in_); for (int i = 0; i < readable; i++) { - *length = (*length << 8) | next_in_[0]; + // The "unsigned char" type cast is intentional to avoid implicit type + // casting of the signed char to unsigned int during bitwise OR which + // causes weird overflow errors. + *length = (*length << 8) | static_cast<unsigned char>(next_in_[0]); bytes_to_read--; next_in_++; avail_in_--; |