From d5648cf2cb1a363b37a4ddcc5b39f6338852ba21 Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Wed, 26 Mar 2025 08:12:08 +0100 Subject: [PATCH] Create `IsTargetWithinTypeBounds` function --- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index 2387ecf458..1c7472822e 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -323,6 +323,11 @@ public: }; } // namespace +template +bool IsTargetWithinTypeBounds(u8 target) { + return target >= std::numeric_limits::min() && target <= std::numeric_limits::max(); +} + void FIFOAnalyzer::UpdateDetails() { // Clearing the detail list can update the selection, which causes UpdateDescription to be called @@ -364,6 +369,7 @@ void FIFOAnalyzer::UpdateDetails() while (object_offset < object_size) { const u32 start_offset = object_offset; + ASSERT(IsTargetWithinTypeBounds(start_offset)); m_object_data_offsets.push_back(start_offset); object_offset += OpcodeDecoder::RunCommand(&fifo_frame.fifoData[object_start + start_offset], @@ -508,6 +514,10 @@ void FIFOAnalyzer::ShowSearchResult(size_t index) const auto& result = m_search_results[index]; + ASSERT(IsTargetWithinTypeBounds(result.m_frame)); + ASSERT(IsTargetWithinTypeBounds(result.m_object_idx)); + ASSERT(IsTargetWithinTypeBounds(result.m_cmd)); + QTreeWidgetItem* object_item = m_tree_widget->topLevelItem(0)->child(result.m_frame)->child(result.m_object_idx);