Skip to content

Fix Incorrect Pointer Increment in the function LasZipper::compress()#17

Merged
tmontaigu merged 1 commit intotmontaigu:masterfrom
jiafulow:fix-incorrect-pointer-increment
Nov 29, 2025
Merged

Fix Incorrect Pointer Increment in the function LasZipper::compress()#17
tmontaigu merged 1 commit intotmontaigu:masterfrom
jiafulow:fix-incorrect-pointer-increment

Conversation

@jiafulow
Copy link
Copy Markdown
Contributor

@jiafulow jiafulow commented Nov 22, 2025

Hi,

First of all, thank you for providing this very useful library! I suspect there is a bug in laspy when handling large point clouds that originates from the LasZipper::compress() function.

1. Fix pointer increment when processing large buffers

When the input buffer is very large, it gets split into several chunks. In those cases, the current code moves in_ptr forward by the number of points, but in_ptr is a byte pointer, so it should move by the number of bytes instead.

This patch changes the increment to:

in_ptr += num_bytes_for_this_iter;

which ensures that the pointer increment logic is correct.

2. Move seekg(0) to after the write (minor improvement)

The patch also executes the reset of the read pointer after writing data into stringstream. This wasn’t a strict bug, as the original ordering often worked, but this ordering makes it clearer and reduces the chance of subtle ordering issues.

Thanks again for the great library and for taking the time to review this patch!

@tmontaigu tmontaigu merged commit 5362a48 into tmontaigu:master Nov 29, 2025
9 checks passed
@tmontaigu
Copy link
Copy Markdown
Owner

Thanks for the fix

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

Successfully merging this pull request may close these issues.

2 participants