From 9ccaffb044d1b881d105266fc9674b67d9f7fdba Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Thu, 13 Oct 2022 21:59:38 -0700 Subject: [PATCH] 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 --- gtk/Session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/Session.cc b/gtk/Session.cc index d48c92a47..20445eebb 100644 --- a/gtk/Session.cc +++ b/gtk/Session.cc @@ -198,7 +198,7 @@ TorrentModelColumns const torrent_cols; Glib::RefPtr Session::Impl::get_core_ptr() const { core_.reference(); - return Glib::RefPtr(&core_); + return Glib::make_refptr_for_instance(&core_); } /***