Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect buffer length handling for RGBA color data in readPntsColors function #7895

Open
XinJack opened this issue Mar 27, 2025 · 0 comments

Comments

@XinJack
Copy link

XinJack commented Mar 27, 2025

Describe the bug

The current implementation of the readPntsColors function contains a buffer length error when processing RGBA color data. The Uint8Array initialization for RGBA incorrectly uses nComponents (calculated as 3 * nPts) instead of 4 * nPts, leading to incomplete data reads and potential memory boundary violations.

const rgba = new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGBA.byteOffset, nComponents);

Also, the loop logic is wrong. It should iterates over 4 * nPts rather than nComponents (3 * nPts) with a step of 4. Besides, rgb index should be (i / 4) * 3, (i / 4) * 3 + 1, (i / 4) * 3 + 2 rather than i + 0, i + 1, i + 2.

for (let i = 0; i < nComponents; i += 4) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant