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(axstorage)! Return GString from get_path #170

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

apljungquist
Copy link
Collaborator

@apljungquist apljungquist commented Jan 4, 2025

The old behavior was not sound because CString could try to free the
memory with a different allocator than glib used to allocate it.

crates/axstorage/src/flex.rs:

  • ax_storage_get_storage_id is left untouched because the
    documentation does not state that it must be freed by the user.
  • Don't use GString because, even though glib is already part of
    the public interface, the C API does not guarantee that the paths are
    valid UTF-8 and paths on Linux are not generally guaranteed to be
    valid UTF-8.

apljungquist and others added 2 commits December 12, 2024 17:53
`crates/axstorage/src/flex.rs`:
- Return `GString` instead of `CString` because the latter is
  unsound since the safety preconditions of `CString` are not
  satisfied. In particular there is no guarantee that the allocator
  that `CString` will use to free the memory is the same as the one
  used by `axstorage` to allocate the memory.

Change-Id: I5f1844925917de23d4ae1f920c9b65045237f396
@apljungquist apljungquist requested a review from a team as a code owner January 4, 2025 14:00
@apljungquist apljungquist changed the title fix(axstorage)! Retyr fix(axstorage)! Return GString from get_path Jan 4, 2025
Because paths generally are not guaranteed to be UTF-8 on linux.
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