mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
fix: Crash when reading from modified bytes
This commit is contained in:
@@ -40,7 +40,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (overlays) [[likely]] {
|
||||
for (const auto&[patchOffset, patchData] : getPatches()) {
|
||||
if (patchOffset >= offset && patchOffset <= (offset + size))
|
||||
if (patchOffset >= offset && patchOffset < (offset + size))
|
||||
reinterpret_cast<u8 *>(buffer)[patchOffset - offset] = patchData;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,6 @@ namespace hex::plugin::builtin {
|
||||
if (offset > (this->getActualSize() - size) || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
/*auto currSize = std::fs::file_size(this->m_path);
|
||||
if (this->m_fileSize != currSize) [[unlikely]] {
|
||||
this->m_fileSize = currSize;
|
||||
this->m_file.unmap();
|
||||
this->m_file.map();
|
||||
}*/
|
||||
|
||||
std::memcpy(buffer, this->m_file.getMapping() + offset, size);
|
||||
}
|
||||
|
||||
@@ -73,13 +66,6 @@ namespace hex::plugin::builtin {
|
||||
if ((offset + size) > this->getActualSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
auto currSize = std::fs::file_size(this->m_path);
|
||||
if (this->m_fileSize != currSize) [[unlikely]] {
|
||||
this->m_fileSize = currSize;
|
||||
this->m_file.unmap();
|
||||
this->m_file.map();
|
||||
}
|
||||
|
||||
std::memcpy(this->m_file.getMapping() + offset, buffer, size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user