diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2023-01-02 18:56:25 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2023-01-04 10:41:14 -0800 |
| commit | 6c58ba353caced302f1e4e23eee0de6d59a527a2 (patch) | |
| tree | 5cb386b592f99a695bc4b30d624a145313d9cbd6 /Source/Core/VideoCommon/IndexGenerator.cpp | |
| parent | d91f340c869a1496804a3a2fff493e0ae60c8b53 (diff) | |
IndexGenerator: Add assertion for overflow in GetRemainingIndices
This assertion is currently triggered by Pocoyo Racing (https://bugs.dolphin-emu.org/issues/13136).
Diffstat (limited to 'Source/Core/VideoCommon/IndexGenerator.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/IndexGenerator.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 5d86561ffd..04068e88ec 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -334,6 +334,15 @@ u32 IndexGenerator::GetRemainingIndices(OpcodeDecoder::Primitive primitive) cons max_index >>= 2; // -1 is reserved for primitive restart + max_index = max_index - 1; - return max_index - m_base_index - 1; + if (m_base_index > max_index) [[unlikely]] + { + PanicAlertFmt("GetRemainingIndices would overflow; we've already written too many indices? " + "base index {} > max index {}", + m_base_index, max_index); + return 0; + } + + return max_index - m_base_index; } |
