From 79c3990d50c2d8884fec2aa8c52de2a2db48e4aa Mon Sep 17 00:00:00 2001 From: Yash Tibrewal <yashkt@google.com> Date: Fri, 26 Apr 2019 13:17:44 -0700 Subject: [PATCH] Move declaration order to how it was earlier in optional, and if check for uri --- src/core/ext/filters/client_channel/client_channel.cc | 7 ++++--- src/core/lib/gprpp/optional.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 85fd450ad4..248e7811bb 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1067,9 +1067,10 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) return; } grpc_uri* uri = grpc_uri_parse(server_uri, true); - GPR_ASSERT(uri->path[0] != '\0'); - server_name_.reset( - gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path)); + if (uri != nullptr && uri->path[0] != '\0') { + server_name_.reset( + gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path)); + } grpc_uri_destroy(uri); char* proxy_name = nullptr; grpc_channel_args* new_args = nullptr; diff --git a/src/core/lib/gprpp/optional.h b/src/core/lib/gprpp/optional.h index 87d336ad6d..a8e3ce1505 100644 --- a/src/core/lib/gprpp/optional.h +++ b/src/core/lib/gprpp/optional.h @@ -38,8 +38,8 @@ class Optional { T value() const { return value_; } private: - bool set_ = false; T value_; + bool set_ = false; }; } /* namespace grpc_core */ -- GitLab