some improvement

This commit is contained in:
chloe caruso
2025-01-18 17:16:33 -08:00
parent 0c2e1f324a
commit cd36aa653e
3 changed files with 3214 additions and 3205 deletions

View File

@@ -2532,9 +2532,7 @@ pub const Arguments = struct {
return ctx.throwInvalidArgumentTypeValue("buffer", "TypedArray", buffer_value.?);
};
if (buffer.buffer.len == 0) {
return JSC.Error.ERR_INVALID_ARG_VALUE.throw(ctx, "The argument 'buffer' is empty and cannot be written.", .{});
}
arguments.eat();
@@ -2569,6 +2567,10 @@ pub const Arguments = struct {
defined_length = true;
}
if (buffer.buffer.len == 0) {
return JSC.Error.ERR_INVALID_ARG_VALUE.throw(ctx, "The argument 'buffer' is empty and cannot be written.", .{});
}
if (arguments.next()) |arg_position| {
arguments.eat();

View File

@@ -947,7 +947,14 @@ pub const PathLike = union(enum) {
pub inline fn osPathKernel32(this: PathLike, buf: *bun.PathBuffer) bun.OSPathSliceZ {
if (comptime Environment.isWindows) {
return strings.toKernel32Path(@alignCast(std.mem.bytesAsSlice(u16, buf)), this.slice());
const s = this.slice();
if (bun.strings.hasPrefixComptime(s, "/")) {
const b = bun.PathBufferPool.get();
defer bun.PathBufferPool.put(b);
const resolve = path_handler.PosixToWinNormalizer.resolveCWDWithExternalBuf(b,s) catch @panic("Error while resolving path.");
return strings.toKernel32Path(@alignCast(std.mem.bytesAsSlice(u16, buf)), resolve);
}
return strings.toKernel32Path(@alignCast(std.mem.bytesAsSlice(u16, buf)), s);
}
return sliceZWithForceCopy(this, buf, false);

File diff suppressed because it is too large Load Diff