Fix use-after-free by moving config-reload into the manage cycle

This commit is contained in:
Ben Buhse 2026-01-31 14:08:46 -06:00
commit 4157dd67f6
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
3 changed files with 33 additions and 14 deletions

View file

@ -45,7 +45,7 @@ const XkbBinding = struct {
return xkb_binding;
}
fn destroy(xkb_binding: *XkbBinding) void {
pub fn destroy(xkb_binding: *XkbBinding) void {
xkb_binding.xkb_binding_v1.destroy();
utils.allocator.destroy(xkb_binding);
}
@ -137,16 +137,9 @@ const XkbBinding = struct {
log.err("Failed to reload Config. Not deleting old one", .{});
return;
};
// Clean up old one
var it = context.xkb_bindings.bindings.safeIterator(.forward);
while (it.next()) |binding| {
binding.link.remove();
binding.destroy();
}
context.config.destroy();
// Replace the old one
context.config = new_config;
context.initialized = false;
// Send the config to the WM to handle during next manage
context.pending_manage.config = new_config;
context.wm.river_window_manager_v1.manageDirty();
},
.toggle_fullscreen => {
const seat = context.wm.seats.first() orelse return;