Index: mojo/public/cpp/application/application_connection.h |
diff --git a/mojo/public/cpp/application/application_connection.h b/mojo/public/cpp/application/application_connection.h |
index d5d6ddec62140b2707aa4f370f9890a8f9c5730e..ca6ea077ed8742a1895b5ed8cc55396c6ea76d11 100644 |
--- a/mojo/public/cpp/application/application_connection.h |
+++ b/mojo/public/cpp/application/application_connection.h |
@@ -47,10 +47,11 @@ class ApplicationConnection { |
// Connect to the service implementing |Interface|. |
template <typename Interface> |
void ConnectToService(InterfacePtr<Interface>* ptr) { |
- MessagePipe pipe; |
- ptr->Bind(pipe.handle0.Pass()); |
- GetServiceProvider()->ConnectToService(Interface::Name_, |
- pipe.handle1.Pass()); |
+ if (ServiceProvider* sp = GetServiceProvider()) { |
+ MessagePipe pipe; |
+ ptr->Bind(pipe.handle0.Pass()); |
+ sp->ConnectToService(Interface::Name_, pipe.handle1.Pass()); |
+ } |
} |
// The url identifying the application on the other end of this connection. |