fix thing

This commit is contained in:
Zack Radisic
2024-02-29 16:49:34 -08:00
parent f50996e115
commit dd6799556e
2 changed files with 5 additions and 3 deletions

View File

@@ -722,8 +722,10 @@ pub const PipeReader = struct {
},
.array_buffer => {
const array_buf_slice = this.array_buffer.buf.slice();
if (array_buf_slice.len - this.array_buffer.i < bytes.len) return;
@memcpy(array_buf_slice[this.array_buffer.i .. this.array_buffer.i + bytes.len], bytes);
// TODO: We should probably throw error here?
if (this.array_buffer.i >= array_buf_slice.len) return;
const len = @min(array_buf_slice.len - this.array_buffer.i, bytes.len);
@memcpy(array_buf_slice[this.array_buffer.i .. this.array_buffer.i + len], bytes[0..len]);
},
}
}

View File

@@ -446,7 +446,7 @@ describe("bunshell", () => {
});
test("syntax edgecase", async () => {
const buffer = new Uint8Array(8192);
const buffer = new Uint8Array(1 << 20);
const shellProc = await $`FOO=bar BUN_TEST_VAR=1 ${BUN} -e "console.log(JSON.stringify(process.env))"> ${buffer}`;
const str = stringifyBuffer(buffer);