From a56fc78a96b0fc76181dc4ca3c7f6da845c84b04 Mon Sep 17 00:00:00 2001 From: Yang Bin <1420506535@qq.com> Date: Fri, 31 May 2024 21:43:24 +0800 Subject: [PATCH] fix: nullptr caused by failed HttpHandler::SwitchHTTP2()(#560). (#561) --- http/server/HttpHandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http/server/HttpHandler.cpp b/http/server/HttpHandler.cpp index ac492e9f0..54a05c71a 100644 --- a/http/server/HttpHandler.cpp +++ b/http/server/HttpHandler.cpp @@ -153,10 +153,11 @@ void HttpHandler::Close() { } bool HttpHandler::SwitchHTTP2() { - parser.reset(HttpParser::New(HTTP_SERVER, ::HTTP_V2)); - if (parser == NULL) { + HttpParser* http2_parser = HttpParser::New(HTTP_SERVER, ::HTTP_V2); + if (http2_parser == NULL) { return false; } + parser.reset(http2_parser); protocol = HTTP_V2; resp->http_major = req->http_major = 2; resp->http_minor = req->http_minor = 0;