aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-09-08 11:27:27 -0700
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-09-08 11:27:27 -0700
commitf1a20188bd8ffefbcf9e2f1ddb4d85784d6b6b10 (patch)
treeea4f28406613178782abe4a2a4d185e6be4f5b73 /src
parent0269c9c2ef616fa34b0263cbe115b6215fac0a2d (diff)
parent61e461e890ff6bc7e88ca98ad93abbdc0aed6901 (diff)
Merge pull request #3247 from yang-g/fix_build_beta
Guard against empty vector
Diffstat (limited to 'src')
-rw-r--r--src/cpp/server/secure_server_credentials.cc8
-rw-r--r--src/cpp/server/server_builder.cc3
2 files changed, 7 insertions, 4 deletions
diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc
index dfa9229c98..90afebfd2e 100644
--- a/src/cpp/server/secure_server_credentials.cc
+++ b/src/cpp/server/secure_server_credentials.cc
@@ -101,7 +101,9 @@ void AuthMetadataProcessorAyncWrapper::InvokeProcessor(
0,
{{nullptr, nullptr, nullptr, nullptr}}});
}
- cb(user_data, &consumed_md[0], consumed_md.size(), &response_md[0],
+ auto consumed_md_data = consumed_md.empty() ? nullptr : &consumed_md[0];
+ auto response_md_data = response_md.empty() ? nullptr : &response_md[0];
+ cb(user_data, consumed_md_data, consumed_md.size(), response_md_data,
response_md.size(), static_cast<grpc_status_code>(status.error_code()),
status.error_message().c_str());
}
@@ -130,8 +132,8 @@ std::shared_ptr<ServerCredentials> SslServerCredentials(
}
grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create(
options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
- &pem_key_cert_pairs[0], pem_key_cert_pairs.size(),
- options.force_client_auth, nullptr);
+ pem_key_cert_pairs.empty() ? nullptr : &pem_key_cert_pairs[0],
+ pem_key_cert_pairs.size(), options.force_client_auth, nullptr);
return std::shared_ptr<ServerCredentials>(
new SecureServerCredentials(c_creds));
}
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index b739cbfe62..99bc8147a0 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -128,7 +128,8 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
*port->selected_port = r;
}
}
- if (!server->Start(&cqs_[0], cqs_.size())) {
+ auto cqs_data = cqs_.empty() ? nullptr : &cqs_[0];
+ if (!server->Start(cqs_data, cqs_.size())) {
return nullptr;
}
return server;