a9bfb7c924
A user reported a crash that only reproduces when preloading a hardened malloc implementation. From the stack trace, this use-after-free seems to be the most likely cause. Yay hardened malloc!
36 lines
1.2 KiB
Zig
36 lines
1.2 KiB
Zig
const Self = @This();
|
|
|
|
const std = @import("std");
|
|
const wlr = @import("wlroots");
|
|
const wl = @import("wayland").server.wl;
|
|
|
|
const server = &@import("main.zig").server;
|
|
const util = @import("util.zig");
|
|
|
|
const IdleInhibitorManager = @import("IdleInhibitorManager.zig");
|
|
|
|
inhibitor_manager: *IdleInhibitorManager,
|
|
inhibitor: *wlr.IdleInhibitorV1,
|
|
destroy: wl.Listener(*wlr.IdleInhibitorV1) = wl.Listener(*wlr.IdleInhibitorV1).init(handleDestroy),
|
|
|
|
pub fn init(self: *Self, inhibitor: *wlr.IdleInhibitorV1, inhibitor_manager: *IdleInhibitorManager) !void {
|
|
self.inhibitor_manager = inhibitor_manager;
|
|
self.inhibitor = inhibitor;
|
|
self.destroy.setNotify(handleDestroy);
|
|
inhibitor.events.destroy.add(&self.destroy);
|
|
|
|
inhibitor_manager.idleInhibitCheckActive();
|
|
}
|
|
|
|
fn handleDestroy(listener: *wl.Listener(*wlr.IdleInhibitorV1), _: *wlr.IdleInhibitorV1) void {
|
|
const self = @fieldParentPtr(Self, "destroy", listener);
|
|
self.destroy.link.remove();
|
|
|
|
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
|
|
server.idle_inhibitor_manager.inhibitors.remove(node);
|
|
|
|
self.inhibitor_manager.idleInhibitCheckActive();
|
|
|
|
util.gpa.destroy(node);
|
|
}
|