The following issues were found
src/google/protobuf/no_field_presence_test.cc
1 issues
Line: 233
EXPECT_EQ("test", m.oneof_string());
}
TEST(NoFieldPresenceTest, BasicMessageTest) {
proto2_nofieldpresence_unittest::TestAllTypes message;
// Check default values, fill all fields, check values. We just want to
// exercise the basic getters/setter paths here to make sure no
// field-presence-related changes broke these.
CheckDefaultValues(message);
Reported by Cppcheck.
src/google/protobuf/compiler/objectivec/objectivec_extension.cc
1 issues
Line: 89
Column: 20
CWE codes:
120
vars["root_class_and_method_name"] = root_class_and_method_name_;
const std::string containing_type = ClassName(descriptor_->containing_type());
vars["extended_type"] = ObjCClass(containing_type);
vars["number"] = StrCat(descriptor_->number());
std::vector<std::string> options;
if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated");
if (descriptor_->is_packed()) options.push_back("GPBExtensionPacked");
if (descriptor_->containing_type()->options().message_set_wire_format()) {
Reported by FlawFinder.
src/google/protobuf/compiler/objectivec/objectivec_enum.cc
1 issues
Line: 145
Column: 18
CWE codes:
120
"$name$$deprecated_attribute$ = $value$,\n",
"name", EnumValueName(all_values_[i]),
"deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]),
"value", StrCat(all_values_[i]->number()));
}
printer->Outdent();
printer->Print(
"};\n"
"\n"
Reported by FlawFinder.
src/google/protobuf/preserve_unknown_enum_test.cc
1 issues
Line: 90
// Test that parsing preserves an unknown value in the enum field and does not
// punt it to the UnknownFieldSet.
TEST(PreserveUnknownEnumTest, PreserveParseAndSerialize) {
proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;
FillMessage(&orig_message);
std::string serialized;
orig_message.SerializeToString(&serialized);
Reported by Cppcheck.
src/google/protobuf/proto3_arena_lite_unittest.cc
1 issues
Line: 110
// proto3 and expect the arena support to be fully tested in proto2 unittests
// because proto3 shares most code with proto2.
TEST(Proto3ArenaLiteTest, Parsing) {
TestAllTypes original;
SetAllFields(&original);
Arena arena;
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
Reported by Cppcheck.
src/google/protobuf/proto3_arena_unittest.cc
1 issues
Line: 132
// proto3 and expect the arena support to be fully tested in proto2 unittests
// because proto3 shares most code with proto2.
TEST(Proto3ArenaTest, Parsing) {
TestAllTypes original;
SetAllFields(&original);
Arena arena;
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
Reported by Cppcheck.
src/google/protobuf/reflection_ops.cc
1 issues
Line: 372
Column: 19
CWE codes:
120
}
if (index != -1) {
result.append("[");
result.append(StrCat(index));
result.append("]");
}
result.append(".");
return result;
}
Reported by FlawFinder.
src/google/protobuf/reflection_ops_unittest.cc
1 issues
Line: 59
TestUtil::ExpectAllFieldsSet(message);
}
TEST(ReflectionOpsTest, Copy) {
unittest::TestAllTypes message, message2;
TestUtil::SetAllFields(&message);
ReflectionOps::Copy(message, &message2);
Reported by Cppcheck.
src/google/protobuf/repeated_field.cc
1 issues
Line: 77
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
#endif
total_size_ = new_size;
if (old_rep && old_rep->allocated_size > 0) {
memcpy(rep_->elements, old_rep->elements,
old_rep->allocated_size * sizeof(rep_->elements[0]));
rep_->allocated_size = old_rep->allocated_size;
} else {
rep_->allocated_size = 0;
}
Reported by FlawFinder.
src/google/protobuf/compiler/java/java_plugin_unittest.cc
1 issues
Line: 85
// This test verifies that all the expected insertion points exist. It does
// not verify that they are correctly-placed; that would require actually
// compiling the output which is a bit more than I care to do for this test.
TEST(JavaPluginTest, PluginTest) {
GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test.proto",
"syntax = \"proto2\";\n"
"package foo;\n"
"option java_package = \"\";\n"
"option java_outer_classname = \"Test\";\n"
Reported by Cppcheck.