Skip to content

Commit

Permalink
zig: deallocate a varargs function after applying it
Browse files Browse the repository at this point in the history
This fixes an occasional segmentation fault.
  • Loading branch information
asarhaddon committed Aug 7, 2024
1 parent 3f6a40f commit 857fcaf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion impls/zig/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ pub fn apply_function(allocator: *Allocator, args: MalLinkedList) MalError!*MalT

if(n == -1) {
// Variable arg function
(try linked_list.pop_first(allocator, &args_copy)).delete(allocator);
_ = try linked_list.pop_first(allocator, &args_copy);
defer mal_func.delete(allocator);
defer linked_list.destroy(allocator, &args_copy, false);
return (mal_func.data.FVar.*)(args_copy);
}
Expand Down

0 comments on commit 857fcaf

Please sign in to comment.