Skip to content

Commit

Permalink
Fixed some race conditions and dangling pointers when moving clients …
Browse files Browse the repository at this point in the history
…+ toml parser (#432)
  • Loading branch information
DerjenigeUberMensch authored Sep 22, 2024
1 parent e33ea30 commit 320955e
Show file tree
Hide file tree
Showing 5 changed files with 2,182 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2197,16 +2197,9 @@ unmanage(Client *c, uint8_t destroyed)
if(!c)
{ return;
}
Desktop *desk = c->desktop;
const XCBWindow win = c->win;

if(desk->mon->bar == c)
{ desk->mon->bar = NULL;
}
/* prevent dangling pointer here woops */
if(desk->sel == c)
{ desk->sel = NULL;
}
if(!destroyed)
{
/* TODO causes alot of errors for some reason even if its not "destroyed" */
Expand Down
16 changes: 16 additions & 0 deletions src/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ detach(Client *c)
void
detachcompletely(Client *c)
{
if(c)
{
Desktop *desk = c->desktop;
if(desk)
{
Monitor *m = desk->mon;
if(m->bar == c)
{
m->bar = NULL;
Debug0("Detaching bar? Potential memory leak");
}
if(desk->sel == c)
{ desk->sel = NULL;
}
}
}
detach(c);
detachstack(c);
detachfocus(c);
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "main.h"
#include "hashing.h"
#include "getprop.h"
#include "session.h"
#include "keybinds.h"
/* for HELP/DebugGING see under main() or the bottom */

Expand Down Expand Up @@ -240,6 +241,7 @@ cleanup(void)
{
/* save setting data. */
USSave(&_cfg);
SessionSave();
savesession();
PropDestroy(_wm.handler);
if(!_wm.dpy)
Expand Down
Loading

0 comments on commit 320955e

Please sign in to comment.