summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeWii.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2017-06-09 18:39:30 +0200
committerJosJuice <josjuice@gmail.com>2017-06-09 18:39:30 +0200
commitd2b69f963aff4a0d6f99b379feb1024c06624bb6 (patch)
tree159fd7f7664aa766dc978339e74009a97e07b448 /Source/Core/DiscIO/VolumeWii.cpp
parent9885a2bb287b32fb248d8a8d9a3aa1697b4e3b0d (diff)
VolumeWii: Don't set m_game_partition until we know partition is valid
Without this, we can end up in an inconsistent state where m_game_partition is set to a partition that isn't in the partition maps.
Diffstat (limited to 'Source/Core/DiscIO/VolumeWii.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeWii.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp
index 4b6ef56539..ceb1fa5788 100644
--- a/Source/Core/DiscIO/VolumeWii.cpp
+++ b/Source/Core/DiscIO/VolumeWii.cpp
@@ -65,14 +65,10 @@ VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
continue;
const u64 partition_offset = static_cast<u64>(*read_buffer) << 2;
- // Set m_game_partition if this is the game partition
- if (m_game_partition == PARTITION_NONE)
- {
- const std::optional<u32> partition_type =
- m_pReader->ReadSwapped<u32>(partition_table_offset + (i * 8) + 4);
- if (partition_type == u32(0))
- m_game_partition = Partition(partition_offset);
- }
+ // Check if this is the game partition
+ const bool is_game_partition =
+ m_game_partition == PARTITION_NONE &&
+ m_pReader->ReadSwapped<u32>(partition_table_offset + (i * 8) + 4) == u32(0);
// Read ticket
std::vector<u8> ticket_buffer(sizeof(IOS::ES::Ticket));
@@ -113,6 +109,8 @@ VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
m_partition_keys[partition] = std::move(aes_context);
m_partition_tickets[partition] = std::move(ticket);
m_partition_tmds[partition] = std::move(tmd);
+ if (is_game_partition)
+ m_game_partition = partition;
}
}
}