aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/wire_format_lite.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/wire_format_lite.cc')
-rw-r--r--src/google/protobuf/wire_format_lite.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc
index e46ac400..3b139e37 100644
--- a/src/google/protobuf/wire_format_lite.cc
+++ b/src/google/protobuf/wire_format_lite.cc
@@ -47,8 +47,8 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-
namespace google {
+
namespace protobuf {
namespace internal {
@@ -123,6 +123,8 @@ WireFormatLite::kWireTypeForFieldType[MAX_FIELD_TYPE + 1] = {
bool WireFormatLite::SkipField(
io::CodedInputStream* input, uint32 tag) {
+ // Field number 0 is illegal.
+ if (WireFormatLite::GetTagFieldNumber(tag) == 0) return false;
switch (WireFormatLite::GetTagWireType(tag)) {
case WireFormatLite::WIRETYPE_VARINT: {
uint64 value;
@@ -168,6 +170,8 @@ bool WireFormatLite::SkipField(
bool WireFormatLite::SkipField(
io::CodedInputStream* input, uint32 tag, io::CodedOutputStream* output) {
+ // Field number 0 is illegal.
+ if (WireFormatLite::GetTagFieldNumber(tag) == 0) return false;
switch (WireFormatLite::GetTagWireType(tag)) {
case WireFormatLite::WIRETYPE_VARINT: {
uint64 value;
@@ -340,6 +344,8 @@ bool WireFormatLite::ReadPackedEnumPreserveUnknowns(
return true;
}
+#if !defined(PROTOBUF_LITTLE_ENDIAN)
+
namespace {
void EncodeFixedSizeValue(float v, uint8* dest) {
WireFormatLite::WriteFloatNoTagToArray(v, dest);
@@ -370,6 +376,8 @@ void EncodeFixedSizeValue(bool v, uint8* dest) {
}
} // anonymous namespace
+#endif // !defined(PROTOBUF_LITTLE_ENDIAN)
+
template <typename CType>
static void WriteArray(const CType* a, int n, io::CodedOutputStream* output) {
#if defined(PROTOBUF_LITTLE_ENDIAN)