summaryrefslogtreecommitdiff
path: root/src/dbus/server/session.cpp
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2012-07-10 06:37:10 +0000
committerPatrick Ohly <patrick.ohly@intel.com>2012-07-10 06:37:10 +0000
commit31051c0b9e4abba6798684271b1eed9dc6b93893 (patch)
tree9ac86168570d5796212b075385bf212617adffd7 /src/dbus/server/session.cpp
parent663a7063e4524370a9b5819866970f71b307993c (diff)
D-Bus server: use weak pointers with asynchronous D-Bus calls
An asynchronous D-Bus call will invoke the callback even if the call instance itself was already deleted. Therefore binding the this pointer of the call instance owner is not safe. This caused use-after-free errors in local sync (found during testing). Use weak pointers as a precaution where it can be done easily. Some remaining start() calls still need to be converted.
Diffstat (limited to 'src/dbus/server/session.cpp')
-rw-r--r--src/dbus/server/session.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dbus/server/session.cpp b/src/dbus/server/session.cpp
index f8de03a1..157f153e 100644
--- a/src/dbus/server/session.cpp
+++ b/src/dbus/server/session.cpp
@@ -28,6 +28,7 @@
#include <syncevo/ForkExec.h>
#include <syncevo/SyncContext.h>
+#include <syncevo/BoostHelper.h>
#include <memory>
@@ -408,7 +409,7 @@ void Session::sync2(const std::string &mode, const SessionCommon::SourceModes_t
// the error is recorded before ending the session. Premature
// exits by the helper are handled by D-Bus, which then will abort
// the pending method call.
- m_helper->m_sync.start(params, boost::bind(&Session::dbusResultCb, this, "sync()", _1, _2));
+ m_helper->m_sync.start(params, boost::bind(&Session::dbusResultCb, m_me, "sync()", _1, _2));
}
void Session::abort()
@@ -1193,7 +1194,7 @@ void Session::restore2(const string &dir, bool before, const std::vector<std::st
// helper is ready, tell it what to do
m_helper->m_restore.start(m_configName, dir, before, sources,
- boost::bind(&Session::dbusResultCb, this, "restore()", _1, _2));
+ boost::bind(&Session::dbusResultCb, m_me, "restore()", _1, _2));
}
void Session::execute(const vector<string> &args, const map<string, string> &vars)
@@ -1224,7 +1225,7 @@ void Session::execute2(const vector<string> &args, const map<string, string> &va
// helper is ready, tell it what to do
m_helper->m_execute.start(args, vars,
- boost::bind(&Session::dbusResultCb, this, "execute()", _1, _2));
+ boost::bind(&Session::dbusResultCb, m_me, "execute()", _1, _2));
}
/*Implementation of Session.CheckPresence */