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.
This commit is contained in:
parent
9885a2bb28
commit
d2b69f963a
|
@ -65,14 +65,10 @@ VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
|
||||||
continue;
|
continue;
|
||||||
const u64 partition_offset = static_cast<u64>(*read_buffer) << 2;
|
const u64 partition_offset = static_cast<u64>(*read_buffer) << 2;
|
||||||
|
|
||||||
// Set m_game_partition if this is the game partition
|
// Check if this is the game partition
|
||||||
if (m_game_partition == PARTITION_NONE)
|
const bool is_game_partition =
|
||||||
{
|
m_game_partition == PARTITION_NONE &&
|
||||||
const std::optional<u32> partition_type =
|
m_pReader->ReadSwapped<u32>(partition_table_offset + (i * 8) + 4) == u32(0);
|
||||||
m_pReader->ReadSwapped<u32>(partition_table_offset + (i * 8) + 4);
|
|
||||||
if (partition_type == u32(0))
|
|
||||||
m_game_partition = Partition(partition_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read ticket
|
// Read ticket
|
||||||
std::vector<u8> ticket_buffer(sizeof(IOS::ES::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_keys[partition] = std::move(aes_context);
|
||||||
m_partition_tickets[partition] = std::move(ticket);
|
m_partition_tickets[partition] = std::move(ticket);
|
||||||
m_partition_tmds[partition] = std::move(tmd);
|
m_partition_tmds[partition] = std::move(tmd);
|
||||||
|
if (is_game_partition)
|
||||||
|
m_game_partition = partition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue