From a6599c30b422e62bcd2f8f1622b5c8a896d8fa37 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Fri, 1 Jul 2022 19:49:10 +0530 Subject: [PATCH] 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. --- app/src/main/cpp/skyline/common/interval_map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/common/interval_map.h b/app/src/main/cpp/skyline/common/interval_map.h index 5499c40f..608ebaf2 100644 --- a/app/src/main/cpp/skyline/common/interval_map.h +++ b/app/src/main/cpp/skyline/common/interval_map.h @@ -51,7 +51,7 @@ namespace skyline { EntryGroup(span> 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> intervals, EntryType value) requires std::is_pointer_v { 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; }