Add missing free calls

Co-authored-by: Maschell <Maschell@gmx.de>
This commit is contained in:
Maniac- 2022-02-04 22:42:53 +02:00 committed by GitHub
parent c56897cc75
commit 60fa230e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -93,6 +93,10 @@ bool getQuickBoot() {
auto fileStream = new nn::sl::FileStream; auto fileStream = new nn::sl::FileStream;
auto *fsClient = (FSClient *) memalign(0x40, sizeof(FSClient)); auto *fsClient = (FSClient *) memalign(0x40, sizeof(FSClient));
if (!fsClient) {
DEBUG_FUNCTION_LINE("Couldn't alloc memory for fsClient.");
return false;
}
memset(fsClient, 0, sizeof(*fsClient)); memset(fsClient, 0, sizeof(*fsClient));
FSAddClient(fsClient, FS_ERROR_FLAG_NONE); FSAddClient(fsClient, FS_ERROR_FLAG_NONE);
@ -113,6 +117,7 @@ bool getQuickBoot() {
delete fileStream; delete fileStream;
FSDelClient(fsClient, FS_ERROR_FLAG_NONE); FSDelClient(fsClient, FS_ERROR_FLAG_NONE);
free(fsClient);
nn::sl::Finalize(); nn::sl::Finalize();

View File

@ -29,7 +29,7 @@ static int numberUSBStorageDevicesConnected() {
memset(handle, 0, sizeof(UhsHandle)); memset(handle, 0, sizeof(UhsHandle));
auto *config = (UhsConfig *) memalign(0x40, sizeof(UhsConfig)); auto *config = (UhsConfig *) memalign(0x40, sizeof(UhsConfig));
if (!config) { if (!config) {
free(config); free(handle);
return -2; return -2;
} }
memset(config, 0, sizeof(UhsConfig)); memset(config, 0, sizeof(UhsConfig));
@ -37,9 +37,10 @@ static int numberUSBStorageDevicesConnected() {
config->controller_num = 0; config->controller_num = 0;
uint32_t size = 5120; uint32_t size = 5120;
void *buffer = memalign(0x40, size); void *buffer = memalign(0x40, size);
if (buffer == nullptr) { if (!buffer) {
free(handle); free(handle);
free(config); free(config);
return -3;
} }
memset(buffer, 0, size); memset(buffer, 0, size);
@ -51,7 +52,7 @@ static int numberUSBStorageDevicesConnected() {
free(handle); free(handle);
free(config); free(config);
free(buffer); free(buffer);
return -3; return -4;
} }
UhsInterfaceProfile profiles[10]; UhsInterfaceProfile profiles[10];
@ -65,7 +66,7 @@ static int numberUSBStorageDevicesConnected() {
free(handle); free(handle);
free(config); free(config);
free(buffer); free(buffer);
return -4; return -5;
} }
auto found = 0; auto found = 0;
@ -79,7 +80,7 @@ static int numberUSBStorageDevicesConnected() {
UhsClientClose(handle); UhsClientClose(handle);
free(handle); free(handle);
free(config); free(config);
free(config->buffer); free(buffer);
return found; return found;
} }