From 6f8cd5e267a27357a54cb35a44e4fedfc975c0f0 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 29 Dec 2005 22:39:28 +0000 Subject: Fixing a bug in the Storage::getAccount() function that made the server crash when the first login had a bad password. --- src/dalstorage.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/dalstorage.cpp') diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index 5723a040..c0359754 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -158,7 +158,7 @@ DALStorage::close(void) /** * Get an account by user name. */ -Account* +AccountPtr DALStorage::getAccount(const std::string& userName) { // connect to the database (if not connected yet). @@ -173,7 +173,7 @@ DALStorage::getAccount(const std::string& userName) ); if (it != mAccounts.end()) { - return (it->first).get(); + return it->first; } using namespace dal; @@ -190,7 +190,7 @@ DALStorage::getAccount(const std::string& userName) // if the account is not even in the database then // we have no choice but to return nothing. if (accountInfo.isEmpty()) { - return NULL; + return AccountPtr(NULL); } // create an Account instance @@ -288,10 +288,10 @@ DALStorage::getAccount(const std::string& userName) account->setCharacters(beings); } // End if there are characters. - return account.get(); + return account; } catch (const DbSqlQueryExecFailure& e) { - return NULL; // TODO: Throw exception here + return AccountPtr(NULL); // TODO: Throw exception here } } @@ -303,6 +303,7 @@ void DALStorage::addAccount(const AccountPtr& account) { if (account.get() == 0) { + LOG_WARN("Cannot add a NULL Account.", 0) // maybe we should throw an exception instead return; } -- cgit v1.2.3-60-g2f50