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

Fixed manging windows not freeing memory properly, scan() #398

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,6 @@ manage(XCBWindow win, void *replies[ManageClientLAST])
free(c);
c = NULL;
CLEANUP:
managecleanup(replies);
return c;
}

Expand Down
10 changes: 7 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ scan(void)
XCBGetWindowAttributes **replies = malloc(sizeof(XCBGetWindowAttributes *) * num);
XCBGetWindowAttributes **replystates = malloc(sizeof(XCBGetWindowAttributes *) * num);
XCBWindow *trans = malloc(sizeof(XCBWindow) * num);
uint64_t index;


if(!wa || !wastates || !tfh || !managecookies || !managereplys || !replies || !replystates || !trans)
{
Expand All @@ -1054,11 +1056,11 @@ scan(void)
/* this specifically queries for the state which wa[i] might fail to provide */
wastates[i] = XCBGetWindowPropertyCookie(_wm.dpy, wins[i], wmatom[WMState], 0L, 2L, False, wmatom[WMState]);
tfh[i] = XCBGetTransientForHintCookie(_wm.dpy, wins[i]);
managerequest(wins[i], &managecookies[i * ManageClientLAST]);
index = i * ManageClientLAST;
managerequest(wins[i], managecookies + index);
}

uint8_t hastrans = 0;
uint64_t index;
/* get them replies back */
for(i = 0; i < num; ++i)
{
Expand Down Expand Up @@ -1100,14 +1102,16 @@ scan(void)
index = ManageClientLAST * i;
/* technically we shouldnt have to do this but just in case */
if(!wintoclient(wins[i]))
{ manage(wins[i], managereplys + i);
{ manage(wins[i], managereplys + index);
}
}
}
}
/* cleanup */
for(i = 0; i < num; ++i)
{
index = ManageClientLAST * i;
managecleanup(managereplys + index);
free(replies[i]);
free(replystates[i]);
}
Expand Down
1 change: 1 addition & 0 deletions src/prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ PropUpdateManage(
}
XCBFlush(_wm.dpy);
UnlockMainThread();
managecleanup(replies);
}

void
Expand Down