julianhille / MuhammaraJS

Muhammara a node module with c/cpp bindings to modify PDF with js for node or electron (based/replacement on/of galkhana/hummusjs)
Other
229 stars 46 forks source link

`RangeError: Invalid array length` on `PDFRStreamForBuffer` #334

Closed ericbf closed 11 months ago

ericbf commented 11 months ago

So Array.prototype.slice.call(buffer, 0) throws a RangeError: Invalid array length when calling it on a buffer that’s not even that large (length 142173398). It probably affects smaller ones too, I didn’t try to find the exact cut off point.

I’m on node v18.17.1 and "muhammara": "^4.0.0".

I was able to get it working if I didn’t convert the buffer to an array right away, but only did each slice on read. I’ll open a PR with what I changed that made it work for much larger buffers too.