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 for missing serial_number on macOS #65

Merged
merged 1 commit into from
Oct 18, 2022
Merged

Fix for missing serial_number on macOS #65

merged 1 commit into from
Oct 18, 2022

Conversation

pavel-kokolemin
Copy link
Contributor

CFStringGetCStringPtr was used incorrectly on macOS in get_string_property.

From https://developer.apple.com/documentation/corefoundation/1542133-cfstringgetcstringptr :

This function either returns the requested pointer immediately, with no memory allocations and no copying, in constant time, or returns NULL. If the latter is the result, call an alternative function such as the [CFStringGetCString(::::)] function to extract the characters.

As the result serial_number is some cases was empty. After switching to CFStringGetCString it now always set correctly .

CFStringGetCStringPtr is not guaranteed to succeed,
CFStringGetCString should be used instead.
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

Good catch, thank you!

@jessebraham jessebraham merged commit 08c1b61 into serialport:main Oct 18, 2022
@mlsvrts mlsvrts mentioned this pull request May 18, 2023
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