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

x11: Prevent memory corruption in XrmSetDatabase #1291

Merged
merged 1 commit into from
Mar 1, 2024
Merged
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
7 changes: 7 additions & 0 deletions src/x11/x.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ static void XRM_update_db(void)
XrmDestroyDatabase(db);
}

// Despite what the XrmSetDatabase docs say, it may try to free
// the database, resulting in memory corruption. Prevent that
// by making sure it has no db to act on. If it's past the
// first run, we will have done XrmDestroyDatabase above
// anyway.
xctx.dpy->db = NULL;

db = XrmGetStringDatabase((const char*)prop.value);
XrmSetDatabase(xctx.dpy, db);
}
Expand Down
Loading