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

fix double free resulting from char_p_to_string #49

Merged
merged 1 commit into from
Jan 12, 2021

Conversation

ccbrown
Copy link
Contributor

@ccbrown ccbrown commented Jan 12, 2021

To quote the docs for CString::from_raw:

This should only ever be called with a pointer that was earlier obtained by calling CString::into_raw. Other usage (e.g., trying to take ownership of a string that was allocated by foreign code) is likely to lead to undefined behavior or allocator corruption.

The added test previously would die when the returned string was dropped with:

malloc: *** error for object 0x137952b14: pointer being freed was not allocated

@nbigaouette
Copy link
Owner

Thanks!!

@nbigaouette nbigaouette merged commit 9a27a77 into nbigaouette:master Jan 12, 2021
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