aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-08-08 22:27:18 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-08 22:27:18 -0700
commit450b066cb812ebb69da111de6dd7aa00774266b4 (patch)
tree351ace4d85d849953c0b70bfca2b1510f15c32de /src/string_immutable.zig
parent63f58f40267856ef5e8ff3e8b0c5720a6d870873 (diff)
downloadbun-450b066cb812ebb69da111de6dd7aa00774266b4.tar.gz
bun-450b066cb812ebb69da111de6dd7aa00774266b4.tar.zst
bun-450b066cb812ebb69da111de6dd7aa00774266b4.zip
Fix one of the astro segfaults, also fix bun init version (#4079)
* 4->16 * add assertions * fix version stuff
Diffstat (limited to '')
-rw-r--r--src/string_immutable.zig13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 3aaec1314..fd5bcb00a 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -1480,9 +1480,12 @@ pub fn convertUTF16ToUTF8(list_: std.ArrayList(u8), comptime Type: type, utf16:
pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, comptime Type: type, utf16: Type) ![]u8 {
if (bun.FeatureFlags.use_simdutf and comptime Type == []const u16) {
const length = bun.simdutf.length.utf8.from.utf16.le(utf16);
- // add 4 bytes of padding for SIMDUTF
- var list = try std.ArrayList(u8).initCapacity(allocator, length + 4);
+ // add 16 bytes of padding for SIMDUTF
+ var list = try std.ArrayList(u8).initCapacity(allocator, length + 16);
list = try convertUTF16ToUTF8(list, Type, utf16);
+ if (Environment.allow_assert) {
+ std.debug.assert(list.items.len == length);
+ }
return list.items;
}
@@ -1496,7 +1499,11 @@ pub fn toUTF8ListWithType(list_: std.ArrayList(u8), comptime Type: type, utf16:
var list = list_;
const length = bun.simdutf.length.utf8.from.utf16.le(utf16);
try list.ensureTotalCapacityPrecise(length + 16);
- return convertUTF16ToUTF8(list, Type, utf16);
+ const buf = try convertUTF16ToUTF8(list, Type, utf16);
+ if (Environment.allow_assert) {
+ std.debug.assert(buf.items.len == length);
+ }
+ return buf;
}
return toUTF8ListWithTypeBun(list_, Type, utf16);