From 01ed16ea5f36c1a61468b5f7aa7258d8f39950f8 Mon Sep 17 00:00:00 2001 From: 3Daniel Date: Thu, 28 Jun 2018 21:29:24 +1200 Subject: [PATCH] More corrections to accountListAllUsers --- nx/include/switch/services/acc.h | 8 ++++---- nx/source/services/acc.c | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/nx/include/switch/services/acc.h b/nx/include/switch/services/acc.h index e2d50a63..e9067313 100644 --- a/nx/include/switch/services/acc.h +++ b/nx/include/switch/services/acc.h @@ -39,10 +39,10 @@ Service* accountGetService(void); Result accountGetUserCount(s32* user_count); /** - * @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE - * @param userIDs Pointer to array of user IDs - * @param max_userIDs Maximum number of user IDs to return - * @param actual_total The actual total number of user IDs found + * @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE. + * @param userIDs Pointer to array of user IDs. + * @param max_userIDs Maximum number of user IDs to return. + * @param actual_total The actual total number of user IDs found. */ Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total); diff --git a/nx/source/services/acc.c b/nx/source/services/acc.c index 19c730e4..71e7e4c4 100644 --- a/nx/source/services/acc.c +++ b/nx/source/services/acc.c @@ -112,7 +112,6 @@ static Result _accountListAllUsers(u128* userIDs) Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total) { Result rc=0; - u128 *temp_userIDs; temp_userIDs = malloc(sizeof(u128) * ACC_USER_LIST_SIZE); @@ -126,13 +125,10 @@ Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_tot } if (max_userIDs > total_userIDs) { - max_userIDs = total_userIDs; - } - - for (int i = 0; i < max_userIDs; i++) { - userIDs[i] = temp_userIDs[i]; + memcpy(&max_userIDs, &total_userIDs, sizeof(size_t)); } + memcpy(userIDs, temp_userIDs, sizeof(u128) * max_userIDs); *actual_total = max_userIDs; }