Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: fix module.paths getter causing a crash #8633

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/resolver/resolve_path.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ pub fn joinStringBuf(buf: []u8, parts: anytype, comptime _platform: Platform) []

var count: usize = 0;
for (parts) |part| {
count += if (part.len > 0) part.len + 1 else 0;
if (part.len == 0) continue;
count += part.len + 1;
}

if (count * 2 > temp_buf.len) {
Expand All @@ -1133,9 +1134,7 @@ pub fn joinStringBuf(buf: []u8, parts: anytype, comptime _platform: Platform) []
temp_buf[0] = 0;

for (parts) |part| {
if (part.len == 0) {
continue;
}
if (part.len == 0) continue;

if (written > 0) {
temp_buf[written] = platform.separator();
Expand Down
10 changes: 4 additions & 6 deletions src/resolver/resolver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ pub const Resolver = struct {
const str = brk: {
if (std.fs.path.isAbsolute(sliced.slice())) break :brk sliced.slice();
const dir_path_buf = bufs(.node_modules_paths_buf);
break :brk r.fs.joinBuf(&[_]string{ r.fs.top_level_dir, sliced.slice() }, dir_path_buf);
break :brk bun.path.joinStringBuf(dir_path_buf, &[_]string{ r.fs.top_level_dir, sliced.slice() }, .auto);
};
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
defer arena.deinit();
Expand All @@ -3297,11 +3297,9 @@ pub const Resolver = struct {

break :brk [2]string{ path_without_trailing_slash, "/node_modules" };
};
list.append(
bun.String.createUTF8(
bun.strings.concat(stack_fallback_allocator.get(), &path_parts) catch unreachable,
),
) catch unreachable;
const nodemodules_path = bun.strings.concat(stack_fallback_allocator.get(), &path_parts) catch unreachable;
bun.path.posixToPlatformInPlace(u8, nodemodules_path);
list.append(bun.String.createUTF8(nodemodules_path)) catch unreachable;
dir_info = (r.readDirInfo(std.fs.path.dirname(path_without_trailing_slash) orelse break) catch null) orelse break;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/string_immutable.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5273,7 +5273,7 @@ pub fn concatWithLength(
allocator: std.mem.Allocator,
args: []const string,
length: usize,
) !string {
) ![]u8 {
const out = try allocator.alloc(u8, length);
var remain = out;
for (args) |arg| {
Expand All @@ -5287,7 +5287,7 @@ pub fn concatWithLength(
pub fn concat(
allocator: std.mem.Allocator,
args: []const string,
) !string {
) ![]u8 {
var length: usize = 0;
for (args) |arg| {
length += arg.len;
Expand Down
Loading