mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
memory safety fix for Io.Writer.Allocating.toOwnedSlice*()
don't forget to save the list. this allows a `testing.checkAllAllocationFailures()` test to pass in one of my projects which newly failed since #24329 was merged.
This commit is contained in:
parent
4f5fa959aa
commit
294db62d92
@ -2446,12 +2446,14 @@ pub const Allocating = struct {
|
||||
|
||||
pub fn toOwnedSlice(a: *Allocating) error{OutOfMemory}![]u8 {
|
||||
var list = a.toArrayList();
|
||||
defer a.setArrayList(list);
|
||||
return list.toOwnedSlice(a.allocator);
|
||||
}
|
||||
|
||||
pub fn toOwnedSliceSentinel(a: *Allocating, comptime sentinel: u8) error{OutOfMemory}![:sentinel]u8 {
|
||||
const gpa = a.allocator;
|
||||
var list = toArrayList(a);
|
||||
defer a.setArrayList(list);
|
||||
return list.toOwnedSliceSentinel(gpa, sentinel);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user