Correct IntervalMap insertion end calculation

The `end` pointer for `interval` was incorrectly calculated as `interval.data() + interval.size_bytes()` which would be incorrect when the interval span type is not `u8` as the pointer derived from `interval.data()` would be a pointer to the span type rather than a byte pointer and be subject to arithmetic of that object's size rather than in terms of a byte.
This commit is contained in:
PixelyIon 2022-07-01 19:49:10 +05:30
parent b0910e7b1a
commit a6599c30b4
No known key found for this signature in database
GPG Key ID: 11BC6C3201BC2C05

View File

@ -51,7 +51,7 @@ namespace skyline {
EntryGroup(span<span<T>> lIntervals, EntryType value) : value(std::move(value)) {
intervals.reserve(lIntervals.size());
for (const auto &interval : lIntervals)
intervals.emplace_back(interval.data(), interval.data() + interval.size_bytes());
intervals.emplace_back(interval.data(), interval.data() + interval.size());
}
};
@ -115,7 +115,7 @@ namespace skyline {
GroupHandle Insert(span<span<T>> intervals, EntryType value) requires std::is_pointer_v<AddressType> {
GroupHandle group{groups.emplace(groups.begin(), intervals, std::move(value))};
for (const auto &interval : intervals)
entries.emplace(std::lower_bound(entries.begin(), entries.end(), interval.data()), interval.data(), interval.data() + interval.size_bytes(), group);
entries.emplace(std::lower_bound(entries.begin(), entries.end(), interval.data()), interval.data(), interval.data() + interval.size(), group);
return group;
}