summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorAaron Ruan <i@ar212.com>2025-08-05 22:56:28 +0800
committerAaron Ruan <i@ar212.com>2025-08-05 22:56:28 +0800
commitc1060d56b3088d5f88cdd6142a3fa0cb0749011e (patch)
tree383c12d0c804762c3846afa53686db9b9213df56 /src/os
parentf0272e5fecb1bf34231e35e78d0fb50899f8ff97 (diff)
macOS: properly handle buffer in zh locale canonicalization
Diffstat (limited to 'src/os')
-rw-r--r--src/os/i18n.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/os/i18n.zig b/src/os/i18n.zig
index 2ecae27ac..fa8c125c7 100644
--- a/src/os/i18n.zig
+++ b/src/os/i18n.zig
@@ -133,7 +133,12 @@ pub fn canonicalizeLocale(
locale: []const u8,
) error{NoSpaceLeft}![:0]const u8 {
// Fix zh locales for macOS
- if (fixZhLocale(locale)) |fixed| return fixed;
+ if (fixZhLocale(locale)) |fixed| {
+ if (buf.len < fixed.len + 1) return error.NoSpaceLeft;
+ @memcpy(buf[0..fixed.len], fixed);
+ buf[fixed.len] = 0;
+ return buf[0..fixed.len :0];
+ }
// Buffer must be 16 or at least as long as the locale and null term
if (buf.len < @max(16, locale.len + 1)) return error.NoSpaceLeft;