Avoid iterator invalidation segfault when unregistering a syncpt waiter

erase invalidated `it` leading to a potential segfault if the GPU was very far behind, bail out early to avoid that since there can only be one occurence at most in the buffer anyway.
This commit is contained in:
Billy Laws 2022-01-12 23:01:05 +00:00 committed by PixelyIon
parent e7bfd93541
commit 95685b8207

View File

@ -29,9 +29,12 @@ namespace skyline::soc::host1x {
// We want to ensure the iterator still exists prior to erasing it
// Otherwise, if an invalid iterator was passed in then it could lead to UB
// It is important to avoid UB in that case since the deregister isn't called from a locked context
for (auto it{waiters.begin()}; it != waiters.end(); it++)
if (it == waiter)
for (auto it{waiters.begin()}; it != waiters.end(); it++) {
if (it == waiter) {
waiters.erase(it);
return;
}
}
}
u32 Syncpoint::Increment() {