mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-11-17 18:29:19 +01:00
Fix some memory leaks
This commit is contained in:
parent
c9a655eeee
commit
aec8fc5035
@ -76,13 +76,14 @@ void VirtualMountDevice(const char * path)
|
||||
|
||||
void AddVirtualPath(const char *name, const char *alias, const char *prefix)
|
||||
{
|
||||
if(!VIRTUAL_PARTITIONS)
|
||||
if (!VIRTUAL_PARTITIONS) {
|
||||
VIRTUAL_PARTITIONS = (VIRTUAL_PARTITION *) malloc(sizeof(VIRTUAL_PARTITION));
|
||||
}
|
||||
|
||||
VIRTUAL_PARTITION * tmp = realloc(VIRTUAL_PARTITIONS, sizeof(VIRTUAL_PARTITION)*(MAX_VIRTUAL_PARTITIONS+1));
|
||||
if(!tmp)
|
||||
{
|
||||
VIRTUAL_PARTITION *tmp = realloc(VIRTUAL_PARTITIONS, sizeof(VIRTUAL_PARTITION) * (MAX_VIRTUAL_PARTITIONS + 1));
|
||||
if (!tmp) {
|
||||
free(VIRTUAL_PARTITIONS);
|
||||
VIRTUAL_PARTITIONS = NULL;
|
||||
MAX_VIRTUAL_PARTITIONS = 0;
|
||||
return;
|
||||
}
|
||||
@ -105,7 +106,10 @@ void AddVirtualPath(const char *name, const char *alias, const char *prefix)
|
||||
|
||||
VIRTUAL_PARTITION *tmp = realloc(VIRTUAL_FS, sizeof(VIRTUAL_PARTITION) * (MAX_VIRTUAL_FS + 1));
|
||||
if (!tmp) {
|
||||
if (VIRTUAL_FS) {
|
||||
free(VIRTUAL_FS);
|
||||
VIRTUAL_FS = 0;
|
||||
}
|
||||
MAX_VIRTUAL_FS = 0;
|
||||
return;
|
||||
}
|
||||
@ -150,21 +154,45 @@ void MountVirtualDevices()
|
||||
VirtualMountDevice("usb:/");
|
||||
}
|
||||
|
||||
void UnmountVirtualPaths()
|
||||
{
|
||||
void UnmountVirtualPaths() {
|
||||
uint32_t i = 0;
|
||||
for(i = 0; i < MAX_VIRTUAL_PARTITIONS; i++)
|
||||
{
|
||||
if(VIRTUAL_PARTITIONS[i].name)
|
||||
for (i = 0; i < MAX_VIRTUAL_PARTITIONS; i++) {
|
||||
if (VIRTUAL_PARTITIONS[i].name) {
|
||||
free(VIRTUAL_PARTITIONS[i].name);
|
||||
if(VIRTUAL_PARTITIONS[i].alias)
|
||||
}
|
||||
if (VIRTUAL_PARTITIONS[i].alias) {
|
||||
free(VIRTUAL_PARTITIONS[i].alias);
|
||||
if(VIRTUAL_PARTITIONS[i].prefix)
|
||||
}
|
||||
if (VIRTUAL_PARTITIONS[i].prefix) {
|
||||
free(VIRTUAL_PARTITIONS[i].prefix);
|
||||
}
|
||||
}
|
||||
|
||||
if(VIRTUAL_PARTITIONS)
|
||||
for (i = 0; i < MAX_VIRTUAL_FS_VOL; i++) {
|
||||
if (VIRTUAL_FS_VOL[i].name) {
|
||||
free(VIRTUAL_FS_VOL[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_VIRTUAL_FS; i++) {
|
||||
if (VIRTUAL_FS[i].name) {
|
||||
free(VIRTUAL_FS[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
if (VIRTUAL_PARTITIONS) {
|
||||
free(VIRTUAL_PARTITIONS);
|
||||
}
|
||||
if (VIRTUAL_FS_VOL) {
|
||||
free(VIRTUAL_FS_VOL);
|
||||
}
|
||||
if (VIRTUAL_FS) {
|
||||
free(VIRTUAL_FS);
|
||||
}
|
||||
VIRTUAL_PARTITIONS = NULL;
|
||||
VIRTUAL_FS_VOL = NULL;
|
||||
VIRTUAL_FS = NULL;
|
||||
MAX_VIRTUAL_PARTITIONS = 0;
|
||||
}
|
||||
MAX_VIRTUAL_FS = 0;
|
||||
MAX_VIRTUAL_FS_VOL = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user