1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 07:08:08 +02:00
pdf.js/src
Jonas Jenwald 6bcb4e3ad9 Ensure that parseDefaultAppearance won't attempt to access a not yet defined variable (PR 12831 follow-up)
Note how, in the `if (this.stateManager.stateStack.length !== 0) {` branch, we're attempting to access the not yet defined variable[1] `args`. If this code-path is ever hit, an Error will be thrown and parsing will thus be aborted immediately (likely leading to e.g. rendering bugs).

Note that I found this purely by accident, since I happened to glance at the LGTM report. However, I've since found that the error is also present during the unit-test[2] and with this patch we're actually testing the *intended* thing here.

As part of fixing this, and to avoid re-introducing a similar bug in the future, we'll now instead always reset `args.length` *before* attempting to read the next operator.
Also, we can use the existing `EvaluatorPreprocessor.savedStatesDepth` getter to simplify the save/restore detection a tiny bit.

---
[1] The ESLint rule `no-use-before-define` would have helped catch this problem, but unfortunately we cannot enable that without quite a bit of refactoring all over the code-base.

[2] The unit-test was updated such that it would fail in the `master`-branch.
2021-01-23 15:33:28 +01:00
..
core Ensure that parseDefaultAppearance won't attempt to access a not yet defined variable (PR 12831 follow-up) 2021-01-23 15:33:28 +01:00
display Merge pull request #12836 from calixteman/update_buttons 2021-01-21 14:00:26 -08:00
images Vectorize the logo. 2012-10-29 14:08:52 -04:00
scripting_api Merge pull request #12850 from calixteman/missing_cstes 2021-01-20 11:33:02 -08:00
shared Merge pull request #12838 from calixteman/authors 2021-01-12 02:44:58 -08:00
.eslintrc Re-factor how the ESLint no-var rule is enabled in the src/ folder 2020-10-03 20:15:29 +02:00
doc_helper.js [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
interfaces.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
license_header.js Update the year in the license_header files 2020-01-05 12:14:03 +01:00
license_header_libre.js Update the year in the license_header files 2020-01-05 12:14:03 +01:00
pdf.image_decoders.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
pdf.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
pdf.sandbox.external.js Update the events, used with scripting, to use lower-case names and avoid using DOM events internally in the viewer 2020-12-18 22:10:32 +01:00
pdf.sandbox.js Remove the ENABLE_SCRIPTING build-target, since it's not necessary 2020-12-18 22:10:36 +01:00
pdf.scripting.js Tweak the pdf.scripting.js bundling, to improve overall consistency 2020-10-25 16:36:56 +01:00
pdf.worker.entry.js Update the year in the license_header files 2020-01-05 12:14:03 +01:00
pdf.worker.js Convert the src/pdf.js and src/pdf.worker.js files to use standard import/export statements 2020-05-20 13:18:23 +02:00
worker_loader.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00