mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-05 09:05:09 +01: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;
|
||||
}
|
||||
|
||||
if (copyFunction && copyOffset) {
|
||||
if (copyFunction && (copyOffset != 0 && copyOffset < sizeEnd)) {
|
||||
auto sourceEnd{start + ((copyOffset != -1) ? copyOffset : sizeEnd)};
|
||||
|
||||
for (auto source{start}, destination{pointer}; source < sourceEnd; source++, destination++)
|
||||
@ -59,6 +59,8 @@ namespace skyline {
|
||||
copyOffset -= sizeEnd;
|
||||
}
|
||||
} else {
|
||||
if (copyOffset)
|
||||
copyOffset -= static_cast<size_t>(sizeEnd) * sizeof(Type);
|
||||
std::memcpy(pointer, start, static_cast<size_t>(sizeEnd) * sizeof(Type));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user