diff options
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); |