Skip to content

Release the LASzip writer on save errors and test for leaks - #11

Open
dlubom wants to merge 2 commits into
mainfrom
codex/fix-laz-writer-leak
Open

dlubom wants to merge 2 commits into
mainfrom
codex/fix-laz-writer-leak

Conversation

@dlubom

@dlubom dlubom commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

saveLaz() allocates a LASzip handle before opening the destination file. If opening the file fails, the function returns an empty result. This change gives the handle a scope-bound owner so that error path releases it. After a successful open, a second guard closes the writer before the handle is destroyed on early returns. The normal path still checks both close and destroy errors.

Evidence

  • On Debian Bookworm ARM64 before the fix, saving one point succeeded. Saving into a missing directory returned an empty result and LeakSanitizer reported 2,752 bytes leaked in laszip_create.
  • After the fix, both CTest cases passed under standalone LeakSanitizer. The success case reopens the compressed LAZ file, checks its point count and reads back the point intensity. The failure case checks for an empty result and no output file.
  • A dedicated Linux CI job builds the production writer with the pinned LASzip dependency and runs both tests.

Merge impact

The change is limited to LASzip resource cleanup in saveLaz(). The test and its sanitizer linkage are built separately from the controller package.

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.

1 participant