From 83e17c2953a0a3afe1ee2783b595916cd85a3e06 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Wed, 30 Oct 2013 10:54:19 -0500 Subject: [PATCH] Avoiding 'pc is undefined' failures --- src/core/fonts.js | 10 ++++++++++ test/pdfs/issue3405.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/pdfs/issue3405.pdf.link diff --git a/src/core/fonts.js b/src/core/fonts.js index f4f8ef9a4..5b107f8e5 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3507,6 +3507,11 @@ var Font = (function FontClosure() { callstack.push({data: data, i: i, stackTop: stack.length - 1}); functionsCalled.push(funcId); var pc = ttContext.functionsDefined[funcId]; + if (!pc) { + warn('TT: CALL non-existent function'); + ttContext.hintsValid = false; + return; + } data = pc.data; i = pc.i; } @@ -3527,6 +3532,11 @@ var Font = (function FontClosure() { lastEndf = i; } else { var pc = callstack.pop(); + if (!pc) { + warn('TT: ENDF bad stack'); + ttContext.hintsValid = false; + return; + } var funcId = functionsCalled.pop(); data = pc.data; i = pc.i; diff --git a/test/pdfs/issue3405.pdf.link b/test/pdfs/issue3405.pdf.link new file mode 100644 index 000000000..1e714c617 --- /dev/null +++ b/test/pdfs/issue3405.pdf.link @@ -0,0 +1 @@ +https://dl.dropboxusercontent.com/s/ls9pn5hww7fer8g/pdfPrintDelFor%260%40-CN.pdf?token_hash=AAHBhbxH7bHCtUESjOikWXAh7YQfCczr3lgcn7Fbq9WEUA&disable_range=1 diff --git a/test/test_manifest.json b/test/test_manifest.json index 2297e0161..b66c4cd98 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -918,6 +918,14 @@ "link": true, "type": "eq" }, + { "id": "issue3405", + "file": "pdfs/issue3405.pdf", + "md5": "58bd4bf790f15f849d1c932e3eda0406", + "rounds": 1, + "lastPage": 1, + "link": true, + "type": "eq" + }, { "id": "issue2006", "file": "pdfs/issue2006.pdf", "md5": "71ec73831ece9b508ad20efa6ff28642",