-
Notifications
You must be signed in to change notification settings - Fork 411
Fix crash due to index-out-of-bounds in Feature context-translation #1002
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,13 +490,14 @@ impl<T: sealed::Context> Features<T> { | |
/// Converts `Features<T>` to `Features<C>`. Only known `T` features relevant to context `C` are | ||
/// included in the result. | ||
fn to_context_internal<C: sealed::Context>(&self) -> Features<C> { | ||
let byte_count = C::KNOWN_FEATURE_MASK.len(); | ||
let from_byte_count = T::KNOWN_FEATURE_MASK.len(); | ||
let to_byte_count = C::KNOWN_FEATURE_MASK.len(); | ||
let mut flags = Vec::new(); | ||
for (i, byte) in self.flags.iter().enumerate() { | ||
if i < byte_count { | ||
let known_source_features = T::KNOWN_FEATURE_MASK[i]; | ||
let known_target_features = C::KNOWN_FEATURE_MASK[i]; | ||
flags.push(byte & known_source_features & known_target_features); | ||
if i < from_byte_count && i < to_byte_count { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a test case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can later but won't have time this week. Asked Matt and he's fine with me PR'ing a test separately later, lmk what you think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No prob. I don't mind doing it if you want to get this merged in the meantime. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be awesome! 🙏 |
||
let from_known_features = T::KNOWN_FEATURE_MASK[i]; | ||
let to_known_features = C::KNOWN_FEATURE_MASK[i]; | ||
flags.push(byte & from_known_features & to_known_features); | ||
} | ||
} | ||
Features::<C> { flags, mark: PhantomData, } | ||
|
Uh oh!
There was an error while loading. Please reload this page.