Skip to content

Conversation

@pnehrer
Copy link
Contributor

@pnehrer pnehrer commented Jun 5, 2024

The cstr macro uses CString::into_raw() to get the c-compatible string pointer.

However, per Rust doc, into_raw actually leaks the pointer if it isn't reclaimed and deallocated using from_raw.

This PR changes the macro and its usage to:

  1. Create a CString
  2. Keep it alive as we take its pointer (as_ptr)
  3. Pass its as_ptr to the c functions

Copy link
Contributor

@abrown abrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good catch! Looks good to me.

@abrown abrown merged commit 5d4f47a into intel:main Jun 6, 2024
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