Skip to content

Commit d6109f9

Browse files
committed
Fix occasional vector overrun
1 parent 964cafd commit d6109f9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/process.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ uintptr_t Process::find_pattern(const char *pattern) {
7575
};
7676

7777
const auto pattern_bytes = pattern_to_bytes(pattern);
78-
const auto pattern_size = pattern_bytes.size();
7978

8079
uintptr_t cur_address = 0;
8180
// this is an osu-specific optimization
@@ -105,10 +104,10 @@ uintptr_t Process::find_pattern(const char *pattern) {
105104
auto buffer = std::vector<std::byte>(info.RegionSize);
106105
read_memory<std::byte>(cur_address, buffer.data(), buffer.size());
107106

108-
for (size_t j = 0; j < buffer.size(); j++) {
107+
for (size_t j = 0; j < buffer.size() - pattern_bytes.size(); j++) {
109108
bool hit = true;
110109

111-
for (size_t k = 0; k < pattern_size; k++) {
110+
for (size_t k = 0; k < pattern_bytes.size(); k++) {
112111
if (pattern_bytes[k] == -1) {
113112
continue;
114113
}

0 commit comments

Comments
 (0)