Fix packed alignment of LSLaunchURLSpec
#102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LSLaunchURLSpec
is defined insrc/macos.rs
as:At a glance, you'd think this matches the definition in the C header:
However, there's a catch: the header contains
#pragma pack(push, 2)
, see here, which means that the correct definition in Rust should correspondingly use#[repr(C, packed(2))]
.Effectively, the difference is that the 4 padding bytes that the compiler otherwise inserts between
launchFlags
andasyncRefCon
shouldn't be there. This is somewhat unlikely to be an issue in practice, since the compiler will likely zero out the padding bytes; but if it decided not to, thenLSOpenFromURLSpec
would read a bogusasyncRefCon
pointer.Found this as part of fixing madsmtm/objc2#758, and then I remembered that I had seen
LSLaunchURLSpec
used here too.