From 249aee70105facdfdf0e627be4f0c0d342ce08a0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Apr 2026 14:50:35 -0700 Subject: [PATCH] example/swift-vt-xcframework: fix buffer overflow --- example/swift-vt-xcframework/Sources/main.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/swift-vt-xcframework/Sources/main.swift b/example/swift-vt-xcframework/Sources/main.swift index e7d15fb89..d374f539f 100644 --- a/example/swift-vt-xcframework/Sources/main.swift +++ b/example/swift-vt-xcframework/Sources/main.swift @@ -1,3 +1,4 @@ +import Foundation import GhosttyVt // Create a terminal with a small grid @@ -38,7 +39,8 @@ guard allocResult == GHOSTTY_SUCCESS, let buf else { } print("Plain text (\(len) bytes):") -print(String(cString: buf)) +let data = Data(bytes: buf, count: len) +print(String(data: data, encoding: .utf8) ?? "") ghostty_free(nil, buf, len) ghostty_formatter_free(formatter)