mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Fix one of the astro segfaults, also fix bun init version (#4079)
* 4->16 * add assertions * fix version stuff
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user