Skip to content

Commit

Permalink
Merge pull request #2265 from tengyifei/master
Browse files Browse the repository at this point in the history
Partially revert 3af1853 to fix use-after-free
  • Loading branch information
Alexays committed Jul 4, 2023
2 parents fc632f5 + cd49eef commit 5ef6636
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/sni/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ Host::Host(const std::size_t id, const Json::Value& config, const Bar& bar,

Host::~Host() {
if (bus_name_id_ > 0) {
Gio::DBus::unwatch_name(bus_name_id_);
Gio::DBus::unown_name(bus_name_id_);
bus_name_id_ = 0;
}
if (watcher_id_ > 0) {
Gio::DBus::unwatch_name(watcher_id_);
watcher_id_ = 0;
}
g_cancellable_cancel(cancellable_);
g_clear_object(&cancellable_);
g_clear_object(&watcher_);
Expand Down
4 changes: 4 additions & 0 deletions src/modules/sni/watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Watcher::Watcher()
watcher_(sn_watcher_skeleton_new()) {}

Watcher::~Watcher() {
if (hosts_ != nullptr) {
g_slist_free_full(hosts_, gfWatchFree);
hosts_ = nullptr;
}
if (items_ != nullptr) {
g_slist_free_full(items_, gfWatchFree);
items_ = nullptr;
Expand Down

0 comments on commit 5ef6636

Please sign in to comment.