1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

Re #2987: read_file_system_list() return value memory leak fixed

This commit is contained in:
Damjan Adamic 2015-10-24 19:53:41 +02:00
parent d38cf06b07
commit ee4ea18a3e
3 changed files with 21 additions and 1 deletions

View file

@ -922,4 +922,19 @@ read_file_system_list (bool need_fs_type)
}
}
void free_file_system_list(struct mount_entry * mount_list)
{
struct mount_entry * me;
while (mount_list)
{
me = mount_list->me_next;
free (mount_list->me_devname);
free (mount_list->me_mountdir);
if (mount_list->me_type_malloced)
free (mount_list->me_type);
free (mount_list);
mount_list = me;
}
}
#endif

View file

@ -49,4 +49,6 @@ struct mount_entry
struct mount_entry *read_file_system_list (bool need_fs_type);
void free_file_system_list(struct mount_entry * mount_list);
#endif

View file

@ -411,7 +411,8 @@ QString findMassstoragePath(const QString &filename)
}
#else
struct mount_entry *entry;
entry = read_file_system_list(true);
struct mount_entry *firstEntry;
firstEntry = entry = read_file_system_list(true);
while (entry != NULL) {
if (!drives.contains(entry->me_devname)) {
drives.append(entry->me_devname);
@ -426,11 +427,13 @@ QString findMassstoragePath(const QString &filename)
#else
if (QFile::exists(eepromfile)) {
#endif
free_file_system_list(firstEntry);
return eepromfile;
}
}
entry = entry->me_next;
}
free_file_system_list(firstEntry);
#endif
return QString();