Fix use-after-free bug in profile management

This commit is contained in:
Marianne Gagnon 2015-08-06 19:40:41 -04:00
parent a3abb57480
commit fac5d6550b
3 changed files with 6 additions and 4 deletions

View File

@ -211,7 +211,7 @@ namespace Online
int userid_fetched = input->get("userid", &userid);
setLastOnlineName(username);
m_profile = new OnlineProfile(userid, username, true);
OnlineProfile* profile = new OnlineProfile(userid, username, true);
assert(token_fetched && username_fetched && userid_fetched);
m_online_state = OS_SIGNED_IN;
if(rememberPassword())
@ -219,7 +219,7 @@ namespace Online
saveSession(getOnlineId(), getToken());
}
ProfileManager::get()->addPersistent(m_profile);
m_profile = ProfileManager::get()->addPersistent(profile);
std::string achieved_string("");
// Even if no achievements were sent, we have to call sync

View File

@ -253,7 +253,7 @@ bool ProfileManager::inPersistent(const uint32_t id)
* the friends, while the other could have fetched the achievements.)
* \param profile The profile to make persistent.
*/
void ProfileManager::addPersistent(OnlineProfile * profile)
OnlineProfile* ProfileManager::addPersistent(OnlineProfile * profile)
{
if (inPersistent(profile->getID()))
{
@ -263,6 +263,8 @@ void ProfileManager::addPersistent(OnlineProfile * profile)
{
m_profiles_persistent[profile->getID()] = profile;
}
return m_profiles_persistent[profile->getID()];
} // addPersistent
// ------------------------------------------------------------------------

View File

@ -103,7 +103,7 @@ public:
// ----------------------------------------------------------------
void addToCache(OnlineProfile *profile);
void addPersistent(OnlineProfile *profile);
OnlineProfile* addPersistent(OnlineProfile *profile);
void deleteFromPersistent(const uint32_t id);
void clearPersistent();
void moveToCache(const uint32_t id);