summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2021-09-16 08:13:02 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2021-09-16 08:13:02 +0200
commitbd92c29ef5a3c664c77a64cdabc5346f4e9383db (patch)
tree98113ae47ae5afb3a1d239eded42b219e1366e96 /Source
parent4d1bd54917f097510e814d0ffcd625de6867fcc0 (diff)
Core/CheatSearch: Avoid length underflow on new search.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/CheatSearch.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Source/Core/Core/CheatSearch.cpp b/Source/Core/Core/CheatSearch.cpp
index f83b7f8b9d..1b85cd9d14 100644
--- a/Source/Core/Core/CheatSearch.cpp
+++ b/Source/Core/Core/CheatSearch.cpp
@@ -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)
{