diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2022-12-14 19:05:25 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-12-15 02:56:24 -0500 |
| commit | 83e0e23f8aa2d90495bbf9c3649aa68f7c55c926 (patch) | |
| tree | 47d4660de7134582454d3ef229fe6d516070208a /src/codegen/spirv.zig | |
| parent | 8ff9284c469226faa2be0c73ab27672e1e8a55d1 (diff) | |
| download | zig-83e0e23f8aa2d90495bbf9c3649aa68f7c55c926.tar.gz zig-83e0e23f8aa2d90495bbf9c3649aa68f7c55c926.zip | |
ArrayList.toOwnedSlice: Fix potential for leaks when using errdefer
#13666 introduced a footgun when using `toOwnedSlice` with `errdefer array_list.deinit()`, since `toOwnedSlice` could retain capacity if `resize` failed, meaning it would leak without `deinit` being called. This meant that the only correct way to use `toOwnedSlice` was with `defer` instead of `errdefer` to ensure that the ArrayList would get cleaned up.
Now, toOwnedSlice will now behave similarly to how it did before #13666, in that it will always clear the ArrayList's capacity if the resize/realloc succeeds.
This also reverts commit 05890a12f532ba9d58904a14381ec174b9efe473, which was contingent on the modified toOwnedSlice behavior.
Closes #13946
Diffstat (limited to 'src/codegen/spirv.zig')
0 files changed, 0 insertions, 0 deletions
