ArtifexSoftware / mupdf.js

JavaScript bindings for MuPDF
https://mupdfjs.readthedocs.io
GNU Affero General Public License v3.0
318 stars 17 forks source link

Rearrange exception #84

Closed xeladotbe closed 3 weeks ago

xeladotbe commented 1 month ago

Hello,

I am trying to manipulate a PDF or change the page order, I tried the rearrangePages method, but here I get the following exception:

ERROR Error: Uncaught (in promise): RuntimeError: memory access out of bounds RuntimeError: memory access out of bounds at mupdf-wasm.wasm at mupdf-wasm.wasm at mupdf-wasm.wasm at mupdf-wasm.wasm at Object._wasm_free (mupdf-wasm.js:705:12) at PDFDocument.rearrangePages (mupdf.js:1722:22)

The exception is triggered by the following line in the finally block:

libmupdf._wasm_free(ptr);

But the reordering still works.

Thank you and regards, Alex

jamie-lemon commented 1 month ago

Thanks - this sounds like a bug - we will look into it.

ccxvii commented 3 weeks ago

Can you please provide a (minimal) script along with the PDF file that exhibits this issue.

xeladotbe commented 3 weeks ago

Hey @ccxvii,

you can use the test.pdf from your tests folder: https://github.com/ArtifexSoftware/mupdf.js/blob/master/examples/tests/test.pdf

The exception only occurs if you specify all pages of the PDF file, i.e. PDF file has 3 pages

document.rearrangePages([0, 1]) => no exception document.rearrangePages([0, 1, 2]) =>exception

Hope this helps. I can also provide a minimal script later.

Regards, Alex

xeladotbe commented 3 weeks ago

Hey @ccxvii ,

seems like the issue is gone with the latest release, I can't reproduce it anymore.

Regards, Alex