summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2022-10-21 00:05:39 -0400
committerGravatar Lioncash2022-10-21 00:09:22 -0400
commit0b181eeef4f56a814ea6c9b86d789be3ab8d1ae5 (patch)
tree1b64af71db6e0d5a834aba820a7507c90249efb5
parentMerge pull request #9088 from Fdawgs/chore/images (diff)
downloadyuzu-0b181eeef4f56a814ea6c9b86d789be3ab8d1ae5.tar.gz
yuzu-0b181eeef4f56a814ea6c9b86d789be3ab8d1ae5.tar.xz
yuzu-0b181eeef4f56a814ea6c9b86d789be3ab8d1ae5.zip
hid/npad: Fix copy size in GetSupportedNpadIdTypes
Previously this was passing the size of the vector into memcpy rather than the size in bytes to copy, which would result in a partial read. Thankfully, this function isn't used yet, so this gets rid of a bug before it's able to do anything.
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index 98e4f2af7..ba8a1f786 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -745,8 +745,9 @@ void Controller_NPad::SetSupportedNpadIdTypes(u8* data, std::size_t length) {
745} 745}
746 746
747void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) { 747void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
748 ASSERT(max_length < supported_npad_id_types.size()); 748 const auto copy_amount = supported_npad_id_types.size() * sizeof(u32);
749 std::memcpy(data, supported_npad_id_types.data(), supported_npad_id_types.size()); 749 ASSERT(max_length <= copy_amount);
750 std::memcpy(data, supported_npad_id_types.data(), copy_amount);
750} 751}
751 752
752std::size_t Controller_NPad::GetSupportedNpadIdTypesSize() const { 753std::size_t Controller_NPad::GetSupportedNpadIdTypesSize() const {