Skip to content

Commit 4103d02

Browse files
ClaytonKnittelcopybara-github
authored andcommitted
Fix Any hasbit consistency issue in OSS.
`Any` `value` field is a `bytes` field in OSS, and since cl/792909628 (#22956), `_internal_mutable_*()` accessors for string fields don't set hasbits. This can cause the hasbit to be missing for the `value` field of `Any` after calling `PackFrom`, which will serialize incorrectly. The culprit change was adopted in release 33.0, so it will need to be patched to this version. See #24258. PiperOrigin-RevId: 828033634
1 parent 4986a77 commit 4103d02

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/google/protobuf/compiler/cpp/message.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,15 +1799,14 @@ void MessageGenerator::GenerateAnyMethodDefinition(io::Printer* p) {
17991799
R"cc(
18001800
bool PackFrom(const $pb$::Message& message) {
18011801
$DCHK$_NE(&message, this);
1802-
return $pbi$::InternalPackFrom(message, mutable_type_url(),
1803-
_internal_mutable_value());
1802+
return $pbi$::InternalPackFrom(message, mutable_type_url(), mutable_value());
18041803
}
18051804
bool PackFrom(const $pb$::Message& message,
18061805
::absl::string_view type_url_prefix) {
18071806
$DCHK$_NE(&message, this);
18081807
return $pbi$::InternalPackFrom(message, type_url_prefix,
18091808
mutable_type_url(),
1810-
_internal_mutable_value());
1809+
mutable_value());
18111810
}
18121811
bool UnpackTo($pb$::Message* $nonnull$ message) const {
18131812
return $pbi$::InternalUnpackTo(_internal_type_url(),
@@ -1825,17 +1824,17 @@ void MessageGenerator::GenerateAnyMethodDefinition(io::Printer* p) {
18251824
T, const $pb$::Message&>::value>::type>
18261825
bool PackFrom(const T& message) {
18271826
return $pbi$::InternalPackFrom<T>(
1828-
message, mutable_type_url(), _internal_mutable_value());
1827+
message, mutable_type_url(), mutable_value());
18291828
}
18301829
template <
18311830
typename T,
18321831
class = typename std::enable_if<!std::is_convertible<
18331832
T, const $pb$::Message&>::value>::type>
18341833
bool PackFrom(const T& message,
18351834
::absl::string_view type_url_prefix) {
1836-
return $pbi$::InternalPackFrom<T>(
1837-
message, type_url_prefix, mutable_type_url(),
1838-
_internal_mutable_value());
1835+
return $pbi$::InternalPackFrom<T>(message, type_url_prefix,
1836+
mutable_type_url(),
1837+
mutable_value());
18391838
}
18401839
template <
18411840
typename T,
@@ -1851,15 +1850,14 @@ void MessageGenerator::GenerateAnyMethodDefinition(io::Printer* p) {
18511850
R"cc(
18521851
template <typename T>
18531852
bool PackFrom(const T& message) {
1854-
return $pbi$::InternalPackFrom(message, mutable_type_url(),
1855-
_internal_mutable_value());
1853+
return $pbi$::InternalPackFrom(message, mutable_type_url(), mutable_value());
18561854
}
18571855
template <typename T>
18581856
bool PackFrom(const T& message,
18591857
::absl::string_view type_url_prefix) {
18601858
return $pbi$::InternalPackFrom(message, type_url_prefix,
18611859
mutable_type_url(),
1862-
_internal_mutable_value());
1860+
mutable_value());
18631861
}
18641862
template <typename T>
18651863
bool UnpackTo(T* $nonnull$ message) const {

0 commit comments

Comments
 (0)