From 20b5efa8afabe330834be4243298e4b424e2d22f Mon Sep 17 00:00:00 2001 From: OxyTheCrack Date: Thu, 19 Feb 2026 20:41:12 +0800 Subject: [PATCH] Update httprequest.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. UserVerify方法 内注册行为的flag缺少else语句,导致sql语句无论执行是否成功均会赋值为true 2. UserVerify方法 内 最后可以依靠RAII机制自动释放连接,无需手动释放,此举非必要,可能会导致资源重复释放 --- code/http/httprequest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/http/httprequest.cpp b/code/http/httprequest.cpp index 69bfbb1e..c12768d9 100644 --- a/code/http/httprequest.cpp +++ b/code/http/httprequest.cpp @@ -228,9 +228,10 @@ bool HttpRequest::UserVerify(const string &name, const string &pwd, bool isLogin LOG_DEBUG( "Insert error!"); flag = false; } - flag = true; + else flag = true; } - SqlConnPool::Instance()->FreeConn(sql); + // RAII机制自动释放 + // SqlConnPool::Instance()->FreeConn(sql); LOG_DEBUG( "UserVerify success!!"); return flag; } @@ -264,4 +265,4 @@ std::string HttpRequest::GetPost(const char* key) const { return post_.find(key)->second; } return ""; -} \ No newline at end of file +}