From: Donna Dionne Date: Wed, 26 Aug 2020 17:23:02 +0000 (-0700) Subject: [PATCH] Member variable should not be a reference; causing crash when used in destruc... X-Git-Tag: archive/raspbian/1.30.2-4+rpi1^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=524eb03ff19be6f7837ed3cf9708ea9b77a947c9;p=grpc.git [PATCH] Member variable should not be a reference; causing crash when used in destructor (backport into 1.30.x) Gbp-Pq: Name 16-member_variable_should_not_be_a_reference.patch --- diff --git a/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc b/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc index 96491b68..f1cfb73e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +++ b/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc @@ -169,7 +169,7 @@ class WeightedTargetLb : public LoadBalancingPolicy { // The owning LB policy. RefCountedPtr weighted_target_policy_; - const std::string& name_; + const std::string name_; uint32_t weight_; @@ -288,9 +288,8 @@ void WeightedTargetLb::UpdateLocked(UpdateArgs args) { const std::string& name = p.first; auto it = targets_.find(name); if (it == targets_.end()) { - it = targets_.emplace(std::make_pair(name, nullptr)).first; - it->second = MakeOrphanable( - Ref(DEBUG_LOCATION, "WeightedChild"), it->first); + targets_.emplace(name, MakeOrphanable( + Ref(DEBUG_LOCATION, "WeightedChild"), name)); } } // Update all children.