浏览代码

fix: nullptr caused by failed HttpHandler::SwitchHTTP2()(#560). (#561)

Yang Bin 1 年之前
父节点
当前提交
a56fc78a96
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      http/server/HttpHandler.cpp

+ 3 - 2
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;