From 9b5ccb5218e42a8e75f882e67dc4ebb1547aaf39 Mon Sep 17 00:00:00 2001 From: Yang Bin <1420506535@qq.com> Date: Fri, 31 May 2024 15:31:10 +0800 Subject: [PATCH] fix: nullptr error caused by failed HttpHandler::SwitchHTTP2()(#560). --- http/server/HttpHandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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;