Skip to content

fix: vec of contours size change, use len instead of capacity in dmesh#42

Merged
janhohenheim merged 5 commits intojanhohenheim:mainfrom
PatrickChodowski:main
Jan 29, 2026
Merged

fix: vec of contours size change, use len instead of capacity in dmesh#42
janhohenheim merged 5 commits intojanhohenheim:mainfrom
PatrickChodowski:main

Conversation

@PatrickChodowski
Copy link
Contributor

I encountered panicked at /rerecast-0.2.0/src/contours.rs:131:54: index out of bounds: the len is 275 but the index is 275 which I assume is caused by wrong method to expand the vector capacity. Truncate seems to have no effect if we try to set the size larger than it is currently.

@janhohenheim
Copy link
Owner

Looking at the original, this seems indeed to be the correct way. Thanks! Will merge when CI is green :)

auto-merge was automatically disabled December 9, 2025 16:53

Head branch was pushed to by a user without write access

@PatrickChodowski PatrickChodowski changed the title fix: vec of contours size change fix: vec of contours size change, use len instead of capacity in dmesh Dec 9, 2025
@PatrickChodowski
Copy link
Contributor Author

PatrickChodowski commented Dec 9, 2025

Sorry for using the same PR, I can open a new one if needed. I havent realized its the same branch :/

In detail mesh I am encountering substract with overflow error on dmesh.vertices.reserve(vcap - dmesh.vertices.capacity()); since there is a comparison to vertices.len() I figured len() should be used in ```.reserve()`` calculation too :)

@janhohenheim
Copy link
Owner

janhohenheim commented Dec 9, 2025

Took a little while to think this through, but yes, this looks correct, as the docs for Vec state that reserve(additional) results in len + additional, not capacity + additional
Thanks for the fix!

@janhohenheim janhohenheim disabled auto-merge January 28, 2026 11:51
@janhohenheim janhohenheim merged commit 460ba76 into janhohenheim:main Jan 29, 2026
7 of 8 checks passed
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