From df3ea785d8c30a9503321a3d35ee7d35808f190d Mon Sep 17 00:00:00 2001 From: Xiaoyi Zhang Date: Wed, 4 Mar 2020 15:57:37 -0500 Subject: Patch LTS with the bug fix for `absl::Status::ErasePayload`. (#632) f8fe7bd53bfed601f002f521e34ab4bc083fc28b by Matthew Brown : Ensure a deep copy and proper equality on absl::Status::ErasePayload PiperOrigin-RevId: 298482742 --- absl/status/status.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'absl/status/status.cc') diff --git a/absl/status/status.cc b/absl/status/status.cc index bbc1895e..df3b740f 100644 --- a/absl/status/status.cc +++ b/absl/status/status.cc @@ -147,7 +147,15 @@ void Status::SetPayload(absl::string_view type_url, absl::Cord payload) { bool Status::ErasePayload(absl::string_view type_url) { int index = status_internal::FindPayloadIndexByUrl(GetPayloads(), type_url); if (index != -1) { + PrepareToModify(); GetPayloads()->erase(GetPayloads()->begin() + index); + if (GetPayloads()->empty() && message().empty()) { + // Special case: If this can be represented inlined, it MUST be + // inlined (EqualsSlow depends on this behavior). + StatusCode c = static_cast(raw_code()); + Unref(rep_); + rep_ = CodeToInlinedRep(c); + } return true; } -- cgit v1.2.3