aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@gmail.com>2017-02-14 15:11:47 -0800
committerGravatar GitHub <noreply@github.com>2017-02-14 15:11:47 -0800
commit15360e59cf67a10e73478fdbc3de4e4c1f01a594 (patch)
treee2b3af47d244fd5e674866bf2c7c7bd014aa99d4 /src/google
parent38c238e35e04e13d109397017fcb46082d574be3 (diff)
parent56da82820ecfff29166efd006d26935d9f3d2149 (diff)
Merge pull request #2689 from ckennelly/aliasing-fixed32-fixed64
Avoid aliasing CodedInputStream::buffer_ when parsing little endian integers
Diffstat (limited to 'src/google')
-rw-r--r--src/google/protobuf/io/coded_stream.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 557312d3..399c6248 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -996,8 +996,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian32FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian32Fallback(value);
@@ -1010,8 +1009,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian64FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian64Fallback(value);