diff --git a/src/App.h b/src/App.h index 896f0a1..47e2d72 100644 --- a/src/App.h +++ b/src/App.h @@ -53,14 +53,17 @@ public: TemplatedApp &&missingServerName(fu2::unique_function handler) { - httpContext->getSocketContextData()->missingServerNameHandler = std::move(handler); + if (!constructorFailed()) { + httpContext->getSocketContextData()->missingServerNameHandler = std::move(handler); - us_socket_context_on_server_name(SSL, (struct us_socket_context_t *) httpContext, [](struct us_socket_context_t *context, const char *hostname) { + us_socket_context_on_server_name(SSL, (struct us_socket_context_t *) httpContext, [](struct us_socket_context_t *context, const char *hostname) { + + /* This is the only requirements of being friends with HttpContextData */ + HttpContext *httpContext = (HttpContext *) context; + httpContext->getSocketContextData()->missingServerNameHandler(hostname); + }); + } - /* This is the only requirements of being friends with HttpContextData */ - HttpContext *httpContext = (HttpContext *) context; - httpContext->getSocketContextData()->missingServerNameHandler(hostname); - }); return std::move(*this); }