Skip to content

X11: Fix memory leak when using window embedding #108082

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

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

timothyqiu
Copy link
Member

children are not freed due to early returns.

}
}

// Then check children of children.
for (unsigned int i = 0; i < num_children; i++) {
Window wnd = find_window_from_process_id_internal(p_display, p_process_id, children[i]);
if (wnd != 0) {
XFree(children);
return wnd;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if children is nullptr? The code below seems to guard against that.

Copy link
Member Author

@timothyqiu timothyqiu Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_children is the number of elements in children. Getting into the loop body means children is not null.

This is also why the line above uses children[i] directly.

@akien-mga akien-mga added the cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release label Jun 28, 2025
@Repiteo Repiteo merged commit 4c42faa into godotengine:master Jul 1, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jul 1, 2025

Thanks!

@timothyqiu timothyqiu deleted the x-query-tree branch July 2, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release platform:linuxbsd topic:porting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants