Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/internal/byte_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,9 @@ void ByteString::SetSmall(google::protobuf::Arena* absl_nullable arena,
rep_.header.kind = ByteStringKind::kSmall;
rep_.small.size = string.size();
rep_.small.arena = arena;
std::memcpy(rep_.small.data, string.data(), rep_.small.size);
if (!string.empty()) {
std::memcpy(rep_.small.data, string.data(), rep_.small.size);
}
}

void ByteString::SetSmall(google::protobuf::Arena* absl_nullable arena,
Expand Down
6 changes: 6 additions & 0 deletions common/internal/byte_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ TEST_P(ByteStringTest, Default) {
EXPECT_EQ(GetKind(byte_string), ByteStringKind::kSmall);
}

TEST_P(ByteStringTest, ConstructNullDataStringView) {
ByteString byte_string(GetAllocator(), absl::string_view());
EXPECT_THAT(byte_string, IsEmpty());
EXPECT_EQ(byte_string.GetArena(), GetAllocator().arena());
}

TEST_P(ByteStringTest, ConstructSmallCString) {
ByteString byte_string = ByteString(GetAllocator(), GetSmallString().c_str());
EXPECT_THAT(byte_string, SizeIs(GetSmallStringView().size()));
Expand Down
2 changes: 1 addition & 1 deletion common/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ absl::StatusOr<std::pair<Value, int>> StructValueMixin<Base>::Qualify(
const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
google::protobuf::MessageFactory* absl_nonnull message_factory,
google::protobuf::Arena* absl_nonnull arena) const {
ABSL_DCHECK_GT(qualifiers.size(), 0);
ABSL_DCHECK(!qualifiers.empty());
ABSL_DCHECK(descriptor_pool != nullptr);
ABSL_DCHECK(message_factory != nullptr);
ABSL_DCHECK(arena != nullptr);
Expand Down
Loading