diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index 09f5ec60ccb1b..90235827d114c 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc @@ -8,6 +8,7 @@ // Author: kenton@google.com (Kenton Varda) #include +#include #include #include #include @@ -104,7 +105,7 @@ void SetSomeTypesInEmptyMessageUnknownFields( TEST(ParseVarintTest, Varint32) { auto test_value = [](uint32_t value, int varint_length) { - uint8_t buffer[10]; + uint8_t buffer[10] = {0}; uint8_t* p = io::CodedOutputStream::WriteVarint32ToArray(value, buffer); ASSERT_EQ(p - buffer, varint_length) << "Value = " << value; @@ -131,7 +132,7 @@ TEST(ParseVarintTest, Varint32) { TEST(ParseVarintTest, Varint64) { auto test_value = [](uint64_t value, int varint_length) { - uint8_t buffer[10]; + uint8_t buffer[10] = {0}; uint8_t* p = io::CodedOutputStream::WriteVarint64ToArray(value, buffer); ASSERT_EQ(p - buffer, varint_length) << "Value = " << value; diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index af48e07e94e03..9292d517feebf 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -847,6 +847,7 @@ static const char* VarintParseSlowArm(const char* p, uint64_t* out, } #endif +// The caller must ensure that p points to at least 10 valid bytes. template PROTOBUF_NODISCARD const char* VarintParse(const char* p, T* out) { #if defined(__aarch64__) && defined(ABSL_IS_LITTLE_ENDIAN)