diff options
author | Anubisss <none@none> | 2010-01-23 14:45:58 +0100 |
---|---|---|
committer | Anubisss <none@none> | 2010-01-23 14:45:58 +0100 |
commit | d9cb0702158fd045285f2c0a904cb31a45a3864a (patch) | |
tree | cdc6a7c6a83c6eea603ae296a653fb9f04945aad /src/game/WorldSocket.cpp | |
parent | c784110d87666579f18620a98e1e57118db4a9cf (diff) |
Implement QueryResult_AutoPtr type which is ACE's reference counted auto_ptr(ACE_Refcounted_Auto_Ptr) for QueryResult pointers.
Use this auto_ptr for every DB queries(except QueryNamedResult yet).
This patch guarantees NO memory leaks from QueryResult pointers.
Thanks to raczman for the idea and for the helping to make this patch.
--HG--
branch : trunk
Diffstat (limited to 'src/game/WorldSocket.cpp')
-rw-r--r-- | src/game/WorldSocket.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 3480fd57718..af6ddd4f0e5 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -738,7 +738,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) loginDatabase.escape_string (safe_account); // No SQL injection, username escaped. - QueryResult *result = + QueryResult_AutoPtr result = loginDatabase.PQuery ("SELECT " "id, " //0 "sessionkey, " //1 @@ -798,7 +798,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) packet << uint8 (AUTH_FAILED); SendPacket (packet); - delete result; sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); return -1; } @@ -818,8 +817,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) if (locale >= MAX_LOCALE) locale = LOCALE_enUS; - delete result; - // Checks gmlevel per Realm result = loginDatabase.PQuery ("SELECT " @@ -836,11 +833,10 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) { fields = result->Fetch (); security = fields[1].GetInt32(); - delete result; } // Re-check account ban (same check as in realmd) - QueryResult *banresult = + QueryResult_AutoPtr banresult = loginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 " "UNION " "SELECT 1 FROM ip_banned WHERE ip = '%s'", @@ -852,8 +848,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) packet << uint8 (AUTH_BANNED); SendPacket (packet); - delete banresult; - sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); return -1; } |