The following issues were found
src/google/protobuf/testing/zcgzip.cc
1 issues
src/google/protobuf/arena.cc
1 issues
Line: 470
return impl_.AllocateAligned(n, type);
}
PROTOBUF_FUNC_ALIGN(32)
std::pair<void*, internal::SerialArena::CleanupNode*>
Arena::AllocateAlignedWithCleanup(size_t n, const std::type_info* type) {
return impl_.AllocateAlignedWithCleanup(n, type);
}
Reported by Cppcheck.
src/google/protobuf/any_test.cc
1 issues
Line: 48
(void)metadata;
}
TEST(AnyTest, TestPackAndUnpack) {
protobuf_unittest::TestAny submessage;
submessage.set_int32_value(12345);
protobuf_unittest::TestAny message;
ASSERT_TRUE(message.mutable_any_value()->PackFrom(submessage));
Reported by Cppcheck.
src/google/protobuf/wire_format_lite.h
1 issues
Line: 1464
Column: 3
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
const T* ii = value.data();
const int bytes = n * static_cast<int>(sizeof(ii[0]));
memcpy(target, ii, static_cast<size_t>(bytes));
return target + bytes;
#else
return WritePrimitiveNoTagToArray(value, Writer, target);
#endif
}
Reported by FlawFinder.
src/google/protobuf/wrappers.pb.cc
1 issues
Line: 1888
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DoubleValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(arena);
}
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FloatValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FloatValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FloatValue >(arena);
Reported by Cppcheck.
src/google/protobuf/unknown_field_set_unittest.cc
1 issues
Line: 146
unknown_tags.size());
}
TEST_F(UnknownFieldSetTest, Varint) {
const UnknownField* field = GetField("optional_int32");
ASSERT_TRUE(field != NULL);
ASSERT_EQ(UnknownField::TYPE_VARINT, field->type());
EXPECT_EQ(all_fields_.optional_int32(), field->varint());
Reported by Cppcheck.
src/google/protobuf/util/delimited_message_util_test.cc
1 issues
Line: 85
}
}
TEST(DelimitedMessageUtilTest, FailsAtEndOfStream) {
std::stringstream full_stream;
std::stringstream partial_stream;
{
protobuf_unittest::ForeignMessage message;
Reported by Cppcheck.
src/google/protobuf/util/field_comparator_test.cc
1 issues
Line: 59
TestAllTypes message_2_;
};
TEST_F(DefaultFieldComparatorTest, RecursesIntoGroup) {
const FieldDescriptor* field = descriptor_->FindFieldByName("optionalgroup");
EXPECT_EQ(FieldComparator::RECURSE,
comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));
}
Reported by Cppcheck.
src/google/protobuf/util/field_mask_util_test.cc
1 issues
Line: 86
EXPECT_EQ("#FAIL#", SnakeCaseToCamelCase("foo_bar_"));
}
TEST_F(SnakeCaseCamelCaseTest, CamelToSnake) {
EXPECT_EQ("foo_bar", CamelCaseToSnakeCase("fooBar"));
EXPECT_EQ("_foo_bar", CamelCaseToSnakeCase("FooBar"));
EXPECT_EQ("foo3_bar", CamelCaseToSnakeCase("foo3Bar"));
// "_"s are not allowed.
EXPECT_EQ("#FAIL#", CamelCaseToSnakeCase("foo_bar"));
Reported by Cppcheck.
src/google/protobuf/any.pb.cc
1 issues
Line: 333
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Any >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
Reported by Cppcheck.