diff --git a/http/server/HttpHandler.cpp b/http/server/HttpHandler.cpp index ac492e9f0..bc846e2cb 100644 --- a/http/server/HttpHandler.cpp +++ b/http/server/HttpHandler.cpp @@ -153,8 +153,10 @@ void HttpHandler::Close() { } bool HttpHandler::SwitchHTTP2() { - parser.reset(HttpParser::New(HTTP_SERVER, ::HTTP_V2)); - if (parser == NULL) { + HttpParser *new_parser = HttpParser::New(HTTP_SERVER, ::HTTP_V2); + if (new_parser != NULL) { + parser.reset(new_parser); + } else { return false; } protocol = HTTP_V2;