diff options
| author | JosJuice <josjuice@gmail.com> | 2020-04-10 16:21:51 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-04-24 15:10:36 +0200 |
| commit | cefc2a7baa9a4dba878352ebc3a5c92b63ed295a (patch) | |
| tree | f91bc8362b36689007ed3ccba35e6960ef7ad3d4 /Source/Core/DiscIO/DiscScrubber.cpp | |
| parent | dae2c14f7f215b2da570308a10f533d99fdb80af (diff) | |
DiscIO: Fix edge case where blocks could get scrubbed accidentally
If we start 31 KiB into a 32 KiB block and want to mark 2 KiB
of data as used, we need to mark 2 blocks as used, not just 1.
This problem is avoided when calling MarkAsUsed from
MarkAsUsedE, since MarkAsUsedE aligns to 32 KiB on its own.
Most calls to MarkAsUsed are from MarkAsUsedE, which is why
this hasn't been a noticeable problem in the past.
Diffstat (limited to 'Source/Core/DiscIO/DiscScrubber.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DiscScrubber.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 07d504d72a..706a2cd00d 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -58,8 +58,8 @@ bool DiscScrubber::CanBlockBeScrubbed(u64 offset) const void DiscScrubber::MarkAsUsed(u64 offset, u64 size) { - u64 current_offset = offset; - const u64 end_offset = current_offset + size; + u64 current_offset = Common::AlignDown(offset, CLUSTER_SIZE); + const u64 end_offset = offset + size; DEBUG_LOG(DISCIO, "Marking 0x%016" PRIx64 " - 0x%016" PRIx64 " as used", offset, end_offset); |
