Core/CheatSearch: Avoid length underflow on new search.

This commit is contained in:
Admiral H. Curtiss 2021-09-16 08:13:02 +02:00
parent 4d1bd54917
commit bd92c29ef5
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB

View File

@ -212,9 +212,16 @@ Cheats::NewSearch(const std::vector<Cheats::MemoryRange>& memory_ranges,
for (const Cheats::MemoryRange& range : memory_ranges)
{
if (range.m_length < data_size)
continue;
const u32 increment_per_loop = aligned ? data_size : 1;
const u32 start_address = aligned ? Common::AlignUp(range.m_start, data_size) : range.m_start;
const u64 aligned_length = range.m_length - (start_address - range.m_start);
if (aligned_length < data_size)
continue;
const u64 length = aligned_length - (data_size - 1);
for (u64 i = 0; i < length; i += increment_per_loop)
{