Add non-PRODUCTION/TESTING overflow asserts to various string helper-functions (issue 6759)

This commit is contained in:
Jonas Jenwald 2021-06-27 15:19:02 +02:00
parent d644b66c72
commit 273d8cb746
6 changed files with 52 additions and 4 deletions

View file

@ -588,6 +588,15 @@ function arraysToBytes(arr) {
}
function string32(value) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(
typeof value === "number" && Math.abs(value) < 2 ** 32,
`string32: Unexpected input "${value}".`
);
}
return String.fromCharCode(
(value >> 24) & 0xff,
(value >> 16) & 0xff,