Fix heap buffer overflow in GCMemcardRaw

This commit is contained in:
Nicola Vella 2023-10-08 11:37:43 +02:00 committed by Admiral H. Curtiss
parent 31dfb53152
commit b506bdc401
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 5 additions and 1 deletions

View File

@ -30,7 +30,11 @@ public:
void DoState(PointerWrap& p) override;
private:
bool IsAddressInBounds(u32 address, u32 length) const { return address + length <= (m_memory_card_size - 1); }
bool IsAddressInBounds(u32 address, u32 length) const
{
u64 end_address = static_cast<u64>(address) + static_cast<u64>(length);
return end_address <= static_cast<u64>(m_memory_card_size);
}
std::string m_filename;
std::unique_ptr<u8[]> m_memcard_data;