-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buffer: truncate instead of throw when writing beyond buffer
- Loading branch information
Showing
3 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
let i = 0; | ||
|
||
while (i < 1_000_000) { | ||
const buf = Buffer.from("\x80") | ||
|
||
if (buf[0] !== 194 || buf[1] !== 128) { | ||
console.log("Unexpected return value:", buf, buf[0], buf[1]); | ||
break | ||
} | ||
|
||
i++; | ||
} | ||
|
||
if (i < 1_000_000) { | ||
console.log("FAILED after %d iterations", i); | ||
process.exit(1); | ||
} else { | ||
console.log("PASSED after %d iterations", i); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters