Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash caused by use bar instance after it is freed (use-after-free) #3531

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

yangyingchao
Copy link
Contributor

fixes #3530

@alebastr
Copy link
Contributor

sigc::mem_fun already disconnects the callbacks bound to any instance of sigc::trackable. So the real problem is that the Bar doesn't inherit from trackable.

diff --git a/include/bar.hpp b/include/bar.hpp
index 27bf877d..d079e04c 100644
--- a/include/bar.hpp
+++ b/include/bar.hpp
@@ -54,7 +54,7 @@ class BarIpcClient;
 }
 #endif  // HAVE_SWAY
 
-class Bar {
+class Bar : public sigc::trackable {
  public:
   using bar_mode_map = std::map<std::string, struct bar_mode>;
   static const bar_mode_map PRESET_MODES;

@yangyingchao
Copy link
Contributor Author

sigc::mem_fun already disconnects the callbacks bound to any instance of sigc::trackable. So the real problem is that the Bar doesn't inherit from trackable.

diff --git a/include/bar.hpp b/include/bar.hpp
index 27bf877d..d079e04c 100644
--- a/include/bar.hpp
+++ b/include/bar.hpp
@@ -54,7 +54,7 @@ class BarIpcClient;
 }
 #endif  // HAVE_SWAY
 
-class Bar {
+class Bar : public sigc::trackable {
  public:
   using bar_mode_map = std::map<std::string, struct bar_mode>;
   static const bar_mode_map PRESET_MODES;

Yep, I did not notice that it uses sigc::mem_fun(), I thought it was using std::mem_fun().

Will update and test later.

@Alexays Alexays merged commit c5a4266 into Alexays:master Aug 19, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crash (sometimes) when opening LID
3 participants