From da8cb48933b2a2c7f6fd34db04b65b963cc3e944 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Mon, 7 Mar 2022 02:05:14 +0530 Subject: [PATCH] Fix Interval Map `GetAlignedRecursiveRange` lookup bug Any lookups done using `GetAlignedRecursiveRange` incorrectly added intervals in the exclusive interval entry lookups as the condition for adding them was the reverse of what it should've been due to a last minute refactor, it led to graphical glitches and crashes. This has been fixed and the lookups should return the correct results. --- app/src/main/cpp/skyline/common/interval_map.h | 13 +++++++++++-- 1 file changed, 11 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 658cdff7..5499c40f 100644 --- a/app/src/main/cpp/skyline/common/interval_map.h +++ b/app/src/main/cpp/skyline/common/interval_map.h @@ -187,15 +187,19 @@ namespace skyline { for (const auto &entryInterval2 : recursedEntry->group->intervals) { // Similar to case (2) below but for the recursed entry + bool exclusiveIntervalEntry{true}; auto alignedEntryInterval2{entryInterval2.Align(Alignment)}; auto recursedEntry2{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval2.end)}; for (; recursedEntry2 != entries.begin() && (--recursedEntry2)->start < alignedEntryInterval2.end;) { if (recursedEntry2->end > alignedEntryInterval2.start && recursedEntry2->group != recursedEntry->group && recursedEntry2->group != entry->group) { - intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval2.end), alignedEntryInterval2); + exclusiveIntervalEntry = false; break; } } + + if (exclusiveIntervalEntry) + intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval2.end), alignedEntryInterval2); } } } @@ -203,12 +207,17 @@ namespace skyline { intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval); } else { // Case (2) - We only want to add this interval if it only contains the entry + bool exclusiveIntervalEntry{true}; + for (auto recursedEntry{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval.end)}; recursedEntry != entries.begin() && (--recursedEntry)->start < alignedEntryInterval.end;) { if (recursedEntry->end > alignedEntryInterval.start && recursedEntry->group != entry->group) { - intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval); + exclusiveIntervalEntry = false; break; } } + + if (exclusiveIntervalEntry) + intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval); } } }