Skip to content

Commit 3096b79

Browse files
committed
Prevent invalid memory access on invalid signature
1 parent c0d399e commit 3096b79

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

types/mempatch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class MemoryPatch {
3535
for (auto bit : info.vecPreserve) {
3636
this->vecPreserve.append(bit);
3737
}
38-
this->pAddress = pAddress + (info.offset);
38+
39+
// ignore offset if address is bad
40+
this->pAddress = pAddress ? pAddress + (info.offset) : 0;
3941
}
4042

4143
bool Enable() {
@@ -75,6 +77,10 @@ class MemoryPatch {
7577
}
7678

7779
bool Verify() {
80+
if (!pAddress) {
81+
return false;
82+
}
83+
7884
auto addr = (uint8_t*) pAddress;
7985
for (size_t i = 0; i < this->vecVerify.length(); i++) {
8086
if (vecVerify[i] != '*' && vecVerify[i] != addr[i]) {

0 commit comments

Comments
 (0)