aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/terminal/c/allocator.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/terminal/c/allocator.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/terminal/c/allocator.zig')
-rw-r--r--vendor/libghostty-vt/src/terminal/c/allocator.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/vendor/libghostty-vt/src/terminal/c/allocator.zig b/vendor/libghostty-vt/src/terminal/c/allocator.zig
index ca698f3c..c6732375 100644
--- a/vendor/libghostty-vt/src/terminal/c/allocator.zig
+++ b/vendor/libghostty-vt/src/terminal/c/allocator.zig
@@ -7,11 +7,13 @@ const CAllocator = lib.alloc.Allocator;
/// (or the default allocator if NULL).
///
/// Returns a pointer to the allocated buffer, or NULL if the
-/// allocation failed.
+/// allocation failed or `len` is zero.
pub fn alloc(
alloc_: ?*const CAllocator,
len: usize,
) callconv(lib.calling_conv) ?[*]u8 {
+ // Zig's empty allocation pointer is not safe to expose to foreign runtimes.
+ if (len == 0) return null;
const allocator = lib.alloc.default(alloc_);
const buf = allocator.alloc(u8, len) catch return null;
return buf.ptr;
@@ -47,6 +49,7 @@ test "alloc with null allocator" {
test "alloc zero length" {
const ptr = alloc(&lib.alloc.test_allocator, 0);
defer free(&lib.alloc.test_allocator, ptr, 0);
+ try testing.expectEqual(null, ptr);
}
test "free null pointer" {