From e5c31e3058cd0480f03feb2855ab1bb93b30e2ce Mon Sep 17 00:00:00 2001 From: John Plevyak Date: Thu, 12 Sep 2019 17:45:40 -0700 Subject: [PATCH] Fix potential null pointer dereference. (#103) Signed-off-by: John Plevyak --- source/common/upstream/cluster_manager_impl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index 8880e01ff547..b7466fec42b6 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -453,7 +453,9 @@ bool ClusterManagerImpl::addOrUpdateCluster(const envoy::api::v2::Cluster& clust existing_warming_cluster != warming_clusters_.end()) { // The following init manager remove call is a NOP in the case we are already initialized. It's // just kept here to avoid additional logic. - init_helper_.removeCluster(*existing_active_cluster->second->cluster_); + if (existing_active_cluster != active_clusters_.end()) { + init_helper_.removeCluster(*existing_active_cluster->second->cluster_); + } cm_stats_.cluster_modified_.inc(); } else { cm_stats_.cluster_added_.inc();