ActiveSync: avoid dangling const char pointer

The m_account variable was set to a temporary std::string. Better
copy use a std::string for m_account.
This commit is contained in:
Patrick Ohly 2012-08-31 19:04:20 +00:00
parent a15e8be1c2
commit c3049f3eb5
2 changed files with 9 additions and 7 deletions

View file

@ -68,11 +68,11 @@ void ActiveSyncSource::open()
username.c_str(),
m_context->getConfigName().c_str());
m_account = username.c_str();
m_account = username;
m_folder = getDatabaseID();
// create handler
m_handler.set(eas_sync_handler_new(m_account), "EAS handler");
m_handler.set(eas_sync_handler_new(m_account.c_str()), "EAS handler");
}
void ActiveSyncSource::close()
@ -98,7 +98,10 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string
SE_LOG_DEBUG(this, NULL, "sync key empty, starting slow sync");
m_ids->clear();
} else {
SE_LOG_DEBUG(this, NULL, "sync key %s, starting incremental sync", lastToken.c_str());
SE_LOG_DEBUG(this, NULL, "sync key %s for account '%s' folder '%s', starting incremental sync",
lastToken.c_str(),
m_account.c_str(),
m_folder.c_str());
}
gboolean moreAvailable = TRUE;
@ -219,7 +222,7 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string
}
if (slowSync) {
// tell engine that we need a slow sync
// tell engine that we need a slow sync, if it didn't know already
SE_THROW_EXCEPTION_STATUS(StatusException,
"ActiveSync error: Invalid synchronization key",
STATUS_SLOW_SYNC_508);

View file

@ -135,8 +135,7 @@ class ActiveSyncSource :
// also for other keys if the need ever arises).
m_itemNode(new PrefixConfigNode("item-",
boost::shared_ptr<ConfigNode>(new SafeConfigNode(params.m_nodes.getTrackingNode())))),
m_context(params.m_context),
m_account(0)
m_context(params.m_context)
{
if (!m_context) {
m_context.reset(new SyncConfig());
@ -188,7 +187,7 @@ class ActiveSyncSource :
boost::shared_ptr<SyncConfig> m_context;
/** account ID for libeas, must be set in "username" config property */
const char* m_account;
std::string m_account;
/** folder ID for libeas, optionally set in "database" config property */
std::string m_folder;