summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-01-20 21:32:15 (GMT)
committerSwift Review <review@swift.im>2015-02-05 16:47:43 (GMT)
commitab1fff7fb56de38d9df3c6fba9c4efec9a3042bd (patch)
tree1169779c90d82c471abefc257f33e97a8799711d
parentccaa8342069eaa07d6cb3a4273c83f44883472fe (diff)
downloadswift-ab1fff7fb56de38d9df3c6fba9c4efec9a3042bd.zip
swift-ab1fff7fb56de38d9df3c6fba9c4efec9a3042bd.tar.bz2
Fix ASAN reported use-after-free error
The class connects to SettingsProvider::onSettingChanged in its c-tor but never disconnects from the signal. When an instance is deleted and the signal is called afterwards it will call the method which will try to access class members which have already been deleted. Test-Information: Tested on OS X 10.9.5. ASAN reported it sometimes on exit. Have not been able to reproduc it anymore with this fix. Change-Id: I7f1d815dca87f84a4ae93a5455307e261a1ee329
-rw-r--r--Swift/Controllers/HighlightManager.cpp2
-rw-r--r--Swift/Controllers/HighlightManager.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp
index e2498dc..ed49e72 100644
--- a/Swift/Controllers/HighlightManager.cpp
+++ b/Swift/Controllers/HighlightManager.cpp
@@ -51,7 +51,7 @@ HighlightManager::HighlightManager(SettingsProvider* settings)
{
rules_ = boost::make_shared<HighlightRulesList>();
loadSettings();
- settings_->onSettingChanged.connect(boost::bind(&HighlightManager::handleSettingChanged, this, _1));
+ handleSettingChangedConnection_ = settings_->onSettingChanged.connect(boost::bind(&HighlightManager::handleSettingChanged, this, _1));
}
void HighlightManager::handleSettingChanged(const std::string& settingPath)
diff --git a/Swift/Controllers/HighlightManager.h b/Swift/Controllers/HighlightManager.h
index d37643d..c55990b 100644
--- a/Swift/Controllers/HighlightManager.h
+++ b/Swift/Controllers/HighlightManager.h
@@ -67,10 +67,12 @@ namespace Swift {
std::string rulesToString() const;
static std::vector<HighlightRule> getDefaultRules();
+ private:
SettingsProvider* settings_;
bool storingSettings_;
boost::shared_ptr<HighlightManager::HighlightRulesList> rules_;
+ boost::bsignals::scoped_connection handleSettingChangedConnection_;
};
typedef boost::shared_ptr<const HighlightManager::HighlightRulesList> HighlightRulesListPtr;