mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01: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
1 changed files with 2 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue