git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitdc620377f425359ff273475546e1e530736684f6
parent7d629bea7f
authorIsaac Freund <[email protected]>
date2023-03-04 20:12
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;