diff options
author | 2023-02-10 07:20:11 +0200 | |
---|---|---|
committer | 2023-02-09 21:20:11 -0800 | |
commit | 6052a3edbd985d9e504f8c0fcaa4c6a1a2823ec3 (patch) | |
tree | a186d789d764dfcd2b910b0fffb980cf897f45bd /test/bun.js/buffer.test.js | |
parent | 6fd7c1921e6fcfc4fcb95b2c9ac612de5c288932 (diff) | |
download | bun-6052a3edbd985d9e504f8c0fcaa4c6a1a2823ec3.tar.gz bun-6052a3edbd985d9e504f8c0fcaa4c6a1a2823ec3.tar.zst bun-6052a3edbd985d9e504f8c0fcaa4c6a1a2823ec3.zip |
fix assertion failure (#2033)
Diffstat (limited to 'test/bun.js/buffer.test.js')
-rw-r--r-- | test/bun.js/buffer.test.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/bun.js/buffer.test.js b/test/bun.js/buffer.test.js index 37484328b..6c4e9d721 100644 --- a/test/bun.js/buffer.test.js +++ b/test/bun.js/buffer.test.js @@ -2525,6 +2525,14 @@ it("should not crash on invalid UTF-8 byte sequence", () => { expect(str).toBe("\uFFFD\uFFFD"); }); +it("should not crash on invalid UTF-8 byte sequence with ASCII head", () => { + const buf = Buffer.from([0x42, 0xc0, 0xfd]); + expect(buf.length).toBe(3); + const str = buf.toString(); + expect(str.length).toBe(3); + expect(str).toBe("B\uFFFD\uFFFD"); +}); + it("should not perform out-of-bound access on invalid UTF-8 byte sequence", () => { const buf = Buffer.from([0x01, 0x9a, 0x84, 0x13, 0x12, 0x11, 0x10, 0x09]).subarray(2); expect(buf.length).toBe(6); |