Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10103 from AdmiralCurtiss/cheat-search-length-und…
…erflow

Core/CheatSearch: Avoid length underflow on new search.
  • Loading branch information
lioncash committed Sep 19, 2021
2 parents 31ca114 + bd92c29 commit ca2589f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/Core/Core/CheatSearch.cpp
Expand Up @@ -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)
{
Expand Down

0 comments on commit ca2589f

Please sign in to comment.