diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index 41d009fb9..ad251baeb 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -1390,11 +1390,12 @@ class CFFCompiler { data: [], length: 0, add(data) { - if (data.length <= 65536) { - // The number of arguments is limited, hence we just take 65536 as - // limit because it isn't too high or too low. + try { + // It's possible to exceed the call stack maximum size when trying + // to push too much elements. + // In case of failure, we fallback to the `concat` method. this.data.push(...data); - } else { + } catch { this.data = this.data.concat(data); } this.length = this.data.length; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 161997e7c..dafc349b6 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -598,3 +598,4 @@ !issue16473.pdf !bug1529502.pdf !issue16500.pdf +!issue16538.pdf diff --git a/test/pdfs/issue16538.pdf b/test/pdfs/issue16538.pdf new file mode 100644 index 000000000..827aafe35 Binary files /dev/null and b/test/pdfs/issue16538.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 4d4bb76d0..17e7c36bb 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -7713,5 +7713,12 @@ "value": ["Three", "Five"] } } - } + }, + { + "id": "issue16538", + "file": "pdfs/issue16538.pdf", + "md5": "35b691c3a343f4531bd287b001b67a77", + "rounds": 1, + "type": "eq" + } ]