From 5c5dcdd11728d62a69e53f7a80ec2db8e16c4230 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 20 Jan 2023 07:52:36 -0800 Subject: [PATCH] Fix a bug in which a possibly invalidated swisstable reference is used. The hashtable could have rehashed and invalidated the reference. PiperOrigin-RevId: 503442163 --- src/google/protobuf/compiler/csharp/csharp_primitive_field.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 46cb701f2e2ba..a0bd2e4702d7b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -32,6 +32,7 @@ #include #include +#include #include "google/protobuf/compiler/code_generator.h" #include "absl/strings/str_cat.h" @@ -88,7 +89,8 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { variables_["default_value_access"] = absl::StrCat(property_name, "DefaultValue"); } else { - variables_["default_value_access"] = variables_["default_value"]; + std::string default_value = variables_["default_value"]; + variables_["default_value_access"] = std::move(default_value); } // Declare the field itself.