Skip to content

Commit

Permalink
Merge pull request #1291 from cdown/cdown/2024-02-23/xlib_why
Browse files Browse the repository at this point in the history
x11: Prevent memory corruption in XrmSetDatabase
  • Loading branch information
bynect authored Mar 1, 2024
2 parents d55836f + 3c06946 commit de6fd27
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/x11/x.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,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

0 comments on commit de6fd27

Please sign in to comment.