Skip to content

Commit

Permalink
Fix a bug in which a possibly invalidated swisstable reference is used.
Browse files Browse the repository at this point in the history
The hashtable could have rehashed and invalidated the reference.

PiperOrigin-RevId: 503442163
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 20, 2023
1 parent a8e080b commit 5c5dcdd
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <sstream>
#include <string>
#include <utility>

#include "google/protobuf/compiler/code_generator.h"
#include "absl/strings/str_cat.h"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5c5dcdd

Please sign in to comment.