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
This commit is contained in:
Anubisss
2010-01-23 14:45:58 +01:00
parent c784110d87
commit d9cb070215
76 changed files with 458 additions and 1108 deletions

View File

@@ -154,7 +154,7 @@ void RASocket::OnRead()
///- Escape the Login to allow quotes in names
loginDatabase.escape_string(login);
QueryResult* result = loginDatabase.PQuery("SELECT a.id, aa.gmlevel, aa.RealmID FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = '%s'",login.c_str ());
QueryResult_AutoPtr result = loginDatabase.PQuery("SELECT a.id, aa.gmlevel, aa.RealmID FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = '%s'",login.c_str ());
///- If the user is not found, deny access
if(!result)
@@ -187,7 +187,6 @@ void RASocket::OnRead()
{
stage=LG;
}
delete result;
}
}
break;
@@ -204,13 +203,12 @@ void RASocket::OnRead()
loginDatabase.escape_string(login);
loginDatabase.escape_string(pw);
QueryResult *check = loginDatabase.PQuery(
QueryResult_AutoPtr check = loginDatabase.PQuery(
"SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT('%s',':','%s'))",
login.c_str(), login.c_str(), pw.c_str());
if(check)
{
delete check;
r=GetSocket();
stage=OK;
++iUsers;