Fix some leaks due to sentinel values.

This commit is contained in:
Philippe Pittoli 2025-10-24 17:27:43 +02:00
parent 396a4f83f1
commit 375e9bc363
2 changed files with 3 additions and 3 deletions

View file

@ -15,11 +15,11 @@ pub const Connection = struct {
}; };
t: Connection.Type, t: Connection.Type,
path: ?[]const u8, // Not always needed. path: ?[:0]const u8, // Not always needed.
const Self = @This(); const Self = @This();
pub fn init(t: Connection.Type, path: ?[]const u8) Self { pub fn init(t: Connection.Type, path: ?[:0]const u8) Self {
return Self{ return Self{
.t = t, .t = t,
.path = path, .path = path,

View file

@ -51,7 +51,7 @@ pub const Context = struct {
pub fn init(allocator: std.mem.Allocator) !Self { pub fn init(allocator: std.mem.Allocator) !Self {
const rundir = std.process.getEnvVarOwned(allocator, "RUNDIR") catch |err| switch (err) { const rundir = std.process.getEnvVarOwned(allocator, "RUNDIR") catch |err| switch (err) {
error.EnvironmentVariableNotFound => blk: { error.EnvironmentVariableNotFound => blk: {
break :blk try allocator.dupeZ(u8, "/tmp/.libipc-run/"); break :blk try allocator.dupe(u8, "/tmp/.libipc-run/");
}, },
else => { else => {
return err; return err;