mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-28 06:47:55 +03:00
Account for OOB copyOffsets in CircularBuffer::Read
Caused crashes in Pokemon
This commit is contained in:
parent
0a3cf25823
commit
72473369b6
@ -48,7 +48,7 @@ namespace skyline {
|
|||||||
size = sizeBegin + sizeEnd;
|
size = sizeBegin + sizeEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copyFunction && copyOffset) {
|
if (copyFunction && (copyOffset != 0 && copyOffset < sizeEnd)) {
|
||||||
auto sourceEnd{start + ((copyOffset != -1) ? copyOffset : sizeEnd)};
|
auto sourceEnd{start + ((copyOffset != -1) ? copyOffset : sizeEnd)};
|
||||||
|
|
||||||
for (auto source{start}, destination{pointer}; source < sourceEnd; source++, destination++)
|
for (auto source{start}, destination{pointer}; source < sourceEnd; source++, destination++)
|
||||||
@ -59,6 +59,8 @@ namespace skyline {
|
|||||||
copyOffset -= sizeEnd;
|
copyOffset -= sizeEnd;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (copyOffset)
|
||||||
|
copyOffset -= static_cast<size_t>(sizeEnd) * sizeof(Type);
|
||||||
std::memcpy(pointer, start, static_cast<size_t>(sizeEnd) * sizeof(Type));
|
std::memcpy(pointer, start, static_cast<size_t>(sizeEnd) * sizeof(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user