fix: -Wunsafe-buffer-usage warning in V8Serializer::Serialize() (#43642)

This commit is contained in:
Charles Kerr 2024-09-10 15:05:05 -05:00 committed by GitHub
parent 0cc60500ed
commit a3df950281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,10 +49,12 @@ class V8Serializer : public v8::ValueSerializer::Delegate {
}
DCHECK(wrote_value);
std::pair<uint8_t*, size_t> buffer = serializer_.Release();
DCHECK_EQ(buffer.first, data_.data());
out->encoded_message = base::make_span(buffer.first, buffer.second);
const auto [data_bytes, data_len] = serializer_.Release();
DCHECK_EQ(std::data(data_), data_bytes);
DCHECK_GE(std::size(data_), data_len);
data_.resize(data_len);
out->owned_encoded_message = std::move(data_);
out->encoded_message = out->owned_encoded_message;
out->sender_agent_cluster_id =
blink::WebMessagePort::GetEmbedderAgentClusterID();