config: handle alloc failure in Mapping init
This commit is contained in:
parent
c7c1934b70
commit
4a334829f3
1 changed files with 6 additions and 2 deletions
|
@ -31,8 +31,12 @@ pub fn init(
|
||||||
modifiers: u32,
|
modifiers: u32,
|
||||||
command_args: []const []const u8,
|
command_args: []const []const u8,
|
||||||
) !Self {
|
) !Self {
|
||||||
var owned_args = try allocator.alloc([]u8, command_args.len);
|
const owned_args = try allocator.alloc([]u8, command_args.len);
|
||||||
for (command_args) |arg, i| owned_args[i] = try std.mem.dupe(allocator, u8, arg);
|
errdefer allocator.free(owned_args);
|
||||||
|
for (command_args) |arg, i| {
|
||||||
|
errdefer for (owned_args[0..i]) |a| allocator.free(a);
|
||||||
|
owned_args[i] = try std.mem.dupe(allocator, u8, arg);
|
||||||
|
}
|
||||||
return Self{
|
return Self{
|
||||||
.keysym = keysym,
|
.keysym = keysym,
|
||||||
.modifiers = modifiers,
|
.modifiers = modifiers,
|
||||||
|
|
Loading…
Reference in a new issue