Fix a bug in which a possibly invalidated swisstable reference is used.

The hashtable could have rehashed and invalidated the reference.

PiperOrigin-RevId: 503442163
pull/11596/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent a8e080b48a
commit 5c5dcdd117
  1. 4
      src/google/protobuf/compiler/csharp/csharp_primitive_field.cc

@ -32,6 +32,7 @@
#include <sstream>
#include <string>
#include <utility>
#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.

Loading…
Cancel
Save