From f5f9b526a06b2c395a4ed36e2481603f461562c8 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 4 Mar 2023 20:12:37 +0100 Subject: [PATCH] river: fix a few leaks --- river/LayerSurface.zig | 2 ++ river/LockManager.zig | 1 + river/LockSurface.zig | 3 +++ river/Output.zig | 2 ++ 4 files changed, 8 insertions(+) diff --git a/river/LayerSurface.zig b/river/LayerSurface.zig index fd294f2..2a8a770 100644 --- a/river/LayerSurface.zig +++ b/river/LayerSurface.zig @@ -89,6 +89,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfa layer_surface.destroyPopups(); + layer_surface.popup_tree.node.destroy(); + util.gpa.destroy(layer_surface); } diff --git a/river/LockManager.zig b/river/LockManager.zig index 26d6cf0..fdafc32 100644 --- a/river/LockManager.zig +++ b/river/LockManager.zig @@ -273,6 +273,7 @@ fn handleSurface( assert(manager.lock != null); LockSurface.create(wlr_lock_surface, manager.lock.?) catch { + log.err("out of memory", .{}); wlr_lock_surface.resource.postNoMemory(); }; } diff --git a/river/LockSurface.zig b/river/LockSurface.zig index 0bc4ba4..83f95b3 100644 --- a/river/LockSurface.zig +++ b/river/LockSurface.zig @@ -37,6 +37,7 @@ surface_destroy: wl.Listener(void) = wl.Listener(void).init(handleDestroy), pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLockV1) error{OutOfMemory}!void { const lock_surface = try util.gpa.create(LockSurface); + errdefer util.gpa.destroy(lock_surface); lock_surface.* = .{ .wlr_lock_surface = wlr_lock_surface, @@ -46,6 +47,8 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLoc const output = lock_surface.getOutput(); const tree = try output.locked_content.createSceneSubsurfaceTree(wlr_lock_surface.surface); + errdefer tree.node.destroy(); + try SceneNodeData.attach(&tree.node, .{ .lock_surface = lock_surface }); wlr_lock_surface.output.events.mode.add(&lock_surface.output_mode); diff --git a/river/Output.zig b/river/Output.zig index 65378f3..839fedf 100644 --- a/river/Output.zig +++ b/river/Output.zig @@ -358,6 +358,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void { output.mode.link.remove(); output.present.link.remove(); + output.tree.node.destroy(); + if (output.layout_namespace) |namespace| util.gpa.free(namespace); output.wlr_output.data = 0;