Fix session use after free (GTK client) (#3963)

In GLIB 2.68+ `Glib::RefPtr<>` is an alias for `std::shared_ptr<>` which
has no idea about GLIB's reference counting, thus destroying the object
instead of unreferencing it. Use `Glib::make_refptr_for_instance()` to
construct the smart pointer which passes in a custom reference-aware
deleter for us.

Fixes: #3954
This commit is contained in:
Mike Gelfand
2022-10-13 21:59:38 -07:00
committed by GitHub
parent 4a359fd481
commit 9ccaffb044

View File

@@ -198,7 +198,7 @@ TorrentModelColumns const torrent_cols;
Glib::RefPtr<Session> Session::Impl::get_core_ptr() const Glib::RefPtr<Session> Session::Impl::get_core_ptr() const
{ {
core_.reference(); core_.reference();
return Glib::RefPtr<Session>(&core_); return Glib::make_refptr_for_instance(&core_);
} }
/*** /***